mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-02 21:30:46 +09:00
fix(tenant): stop the gateway release waiting on TenantGateway listeners and certificates (#5086)
## What this PR does
After platform upgrade the tenant `gateway` HelmRelease fails with
`timeout waiting for: [TenantGateway/<namespace>/cozystack status:
'InProgress']`, retries every 30s without end (`RetryOnFailure`) while
holding a helm-controller worker, and parent tenant release that waits
on it fails too.
helm-controller waits on every object of the release with kstatus on
install and on every upgrade, and kstatus reads TenantGateway
`Ready=False/ListenersNotReady` as InProgress. TenantGateway stays there
while any listener certificate is pending, which depends on ACME or DNS
and on routes owned by other releases, so waiting longer doesn't help.
It passed before only because the wait runs inside a Helm action and the
install happened before those listeners showed up.
I added `healthCheckExprs` for `TenantGateway` with `current: "true"`
and pinned `waitStrategy: poller`, because expressions are evaluated
only under poller. Wait stays on. Flux returns InProgress while
`status.observedGeneration` lags `metadata.generation` before it reads
any expression, so release still waits until controller observed the new
TenantGateway spec, but not for listeners or certificates. tenant-root
renders same template and gets the change too. Gateway release that is
already stuck picks this up on its next attempt, after the current one
times out.
New helm-unittest suite
(`packages/apps/tenant/tests/gateway_wait_test.yaml`) pins the strategy
and the whole expression list, checks there is no `disableWait` on
install or upgrade, and that no gateway release is rendered when
`gateway` is unset.
### Downstream repositories
- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:
### Release note
```release-note
fix(tenant): the tenant gateway release no longer times out on upgrade while TenantGateway listener certificates are pending, it waits only until the controller has observed the current TenantGateway spec.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Gateway releases now determine readiness from the gateway resource’s
current status, rather than waiting for its listeners and certificates
to become ready. Releases still wait for the latest resource update to
be observed.
* **Tests**
* Added checks for gateway release readiness behavior and for tenants
configured without a gateway.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from: 1ac83aebd9
This commit is contained in:
2 files changed
+61
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user