diff --git a/packages/apps/tenant/templates/gateway.yaml b/packages/apps/tenant/templates/gateway.yaml index cf7efd53c..ec5e1d619 100644 --- a/packages/apps/tenant/templates/gateway.yaml +++ b/packages/apps/tenant/templates/gateway.yaml @@ -50,6 +50,23 @@ spec: retryInterval: 30s remediation: retries: -1 + {{- /* Listener certificates depend on ACME or DNS and, under HTTP-01, on + routes other releases own, so the TenantGateway sits at + Ready=False/ListenersNotReady while any of them is pending, which + kstatus reads as InProgress until the wait runs out. The expression + replaces kstatus for this kind only. Flux still reads InProgress + while status.observedGeneration lags the generation, before any + expression runs, so the release still waits for the controller to + observe the current TenantGateway spec, never for listener or + certificate health. The strategy is pinned because expressions are + read only under poller, and the UseHelm3Defaults gate turns the + default to legacy. */}} + waitStrategy: + name: poller + healthCheckExprs: + - apiVersion: gateway.cozystack.io/v1alpha1 + kind: TenantGateway + current: "true" valuesFrom: - kind: Secret name: cozystack-values diff --git a/packages/apps/tenant/tests/gateway_wait_test.yaml b/packages/apps/tenant/tests/gateway_wait_test.yaml new file mode 100644 index 000000000..889a3673c --- /dev/null +++ b/packages/apps/tenant/tests/gateway_wait_test.yaml @@ -0,0 +1,44 @@ +suite: tenant gateway HelmRelease waits for the TenantGateway generation, not its certificates + +# A TenantGateway reads Ready=False/ListenersNotReady while any listener's +# certificate is pending, and kstatus reads that as InProgress, so under the +# default wait every upgrade of this release times out and retries. The release +# swaps kstatus for an always-Current expression on that kind. The wait itself +# must stay on: Flux still holds it while status.observedGeneration lags, and +# that is the only gate left between the gateway spec and its controller. The +# list is pinned whole because a `failed` or `inProgress` expression that reads +# status would wait again, at least until the controller's first status write. +templates: + - templates/gateway.yaml + +release: + name: tenant-test + namespace: tenant-test + +tests: + - it: reads the TenantGateway through an expression under the poller wait + set: + gateway: true + asserts: + # Pins the document first: the notExists checks below pass on an empty render. + - equal: + path: metadata.name + value: gateway + - equal: + path: spec.waitStrategy.name + value: poller + - equal: + path: spec.healthCheckExprs + value: + - apiVersion: gateway.cozystack.io/v1alpha1 + kind: TenantGateway + current: "true" + - notExists: + path: spec.install.disableWait + - notExists: + path: spec.upgrade.disableWait + + - it: renders no gateway release when the tenant does not own one + asserts: + - hasDocuments: + count: 0