Files
cozystack/packages/apps
myasnikovdaniil 1ac83aebd9 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 -->
2026-10-27 11:47:15 +05:00
..
2025-08-07 14:07:05 +03:00

How to test packages local

cd packages/core/installer
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
make apply
kubectl delete po -l app=source-controller -n cozy-fluxcd