fix(platform): do not gate cert-manager-issuers on ClusterIssuer readiness (#5210)

## What this PR does

This PR makes the cert-manager-issuers release stop waiting for
ClusterIssuers to become Ready. ClusterIssuer is Ready only after
cert-manager registered an ACME account with the CA, so when
letsencrypt-stage can't reach the staging endpoint, helm upgrade of the
release hangs until timeout with `timeout waiting for:
[ClusterIssuer/letsencrypt-stage status: 'InProgress']`. The release
stays not Ready and every package that dependsOn cozystack.cert-manager
stays in DependencyNotReady, even when letsencrypt-prod works and all
certificates are already issued.

Fix is `healthCheckExprs` with `current: "true"` for ClusterIssuer on
the component, the same mechanism vm-default-images uses. It covers the
prod issuer too, I did not special-case staging because the wait is the
same.

Issuers keep their own status and retry registration, so they start
issuing when the CA is back. Certificate requests that come before that
stay Pending with `IssuerNotReady`, they are not failed.

Downside is that unreachable CA no longer shows up as non-Ready Package.
Only signal left is ClusterIssuer's own Ready condition and Certificates
at `Ready=False`, and there is no alert on ClusterIssuer in monitoring
packages yet.

On a cluster where the release is already stuck, the running upgrade has
to time out first (10m by default), then the retry uses the new spec.

letsencrypt-stage is still rendered on every cluster. Making it optional
needs a migration, because the issuers carry
`platform.cozystack.io/no-delete`, so it is not part of this PR.

Checked on a 3-node dev cluster running v1.7.0. I made the staging ACME
host unreachable from the cert-manager controller, so letsencrypt-stage
went to Ready=False with ErrRegisterACMEAccount, and forced an upgrade
of cert-manager-issuers. Without the expression the release hung in the
upgrade action and 23 releases went to DependencyNotReady within 15
seconds (67 of 124 at the peak). I then added the expression to the
PackageSource by hand, since I did not install a build of this branch.
The stuck upgrade ran until its timeout, the retry came right after it
and the release was Ready within 2 seconds, a second forced upgrade took
8 seconds, and all 124 releases converged with letsencrypt-stage still
False. After I made the host reachable again the issuer registered by
itself in about 30 seconds.

### Screenshots

### 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(platform): the cert-manager-issuers release no longer waits for ClusterIssuers to become Ready, so an unreachable ACME endpoint (staging included) does not hold other platform packages in DependencyNotReady.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Updated cert-manager issuer release checks to use the ClusterIssuer’s
current status and polling. Releases are no longer held up by ACME
readiness, which can remain unavailable even when issuance may recover
without intervention. This also helps prevent dependent packages from
being delayed while waiting for ACME services to become reachable.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
myasnikovdaniil authored and GitHub committed 2026-11-25 18:23:05 +05:00
commit a1be486fb6
2 files changed
+55

No files matched your search

@@ -345,6 +345,52 @@ func TestGoldenImageHelmReleasesWaitForImport(t *testing.T) {
}
}
// TestCertManagerIssuersReleaseIgnoresACMEReadiness builds the HelmRelease spec
// from the shipped cert-manager source. A ClusterIssuer turns Ready only after
// cert-manager has registered an account with the CA, and every package behind
// cozystack.cert-manager dependsOn this release, so a kstatus wait on the
// issuers would let one unreachable CA hold the whole platform rollout.
func TestCertManagerIssuersReleaseIgnoresACMEReadiness(t *testing.T) {
want := []kustomize.CustomHealthCheck{{
APIVersion: "cert-manager.io/v1",
Kind: "ClusterIssuer",
HealthCheckExpressions: kustomize.HealthCheckExpressions{
Current: "true",
},
}}
path := filepath.Join("..", "..", "packages", "core", "platform", "sources", "cert-manager.yaml")
data, err := os.ReadFile(path)
if err != nil {
t.Fatalf("read %s: %v", path, err)
}
var ps cozyv1alpha1.PackageSource
if err := yaml.Unmarshal(data, &ps); err != nil {
t.Fatalf("unmarshal %s: %v", path, err)
}
var install *cozyv1alpha1.ComponentInstall
for _, v := range ps.Spec.Variants {
for _, c := range v.Components {
if c.Name == "cert-manager-issuers" {
install = c.Install
}
}
}
if install == nil {
t.Fatalf("%s: component cert-manager-issuers has no install block", path)
}
spec := (&PackageReconciler{}).buildHelmReleaseSpec(install, "x")
if !reflect.DeepEqual(spec.HealthCheckExprs, want) {
t.Errorf("HealthCheckExprs = %+v, want %+v", spec.HealthCheckExprs, want)
}
if spec.WaitStrategy == nil || spec.WaitStrategy.Name != helmv2.WaitStrategyPoller {
t.Errorf("WaitStrategy = %+v, want poller: the expressions are not evaluated under any other strategy", spec.WaitStrategy)
}
}
// Memory policy state lives on a Namespace, which fake clients do not create
// implicitly when a namespaced fixture is added.
func memoryTestClientBuilder(scheme *runtime.Scheme) *fake.ClientBuilder {
@@ -34,3 +34,12 @@ spec:
releaseName: cert-manager-issuers
dependsOn:
- cert-manager
# A ClusterIssuer is Ready only after cert-manager has registered an
# ACME account with the CA. Under kstatus that holds this release, and
# through dependsOn every package behind cozystack.cert-manager, for as
# long as the CA is unreachable. Issuance fails and recovers on its own
# in that window; the platform rollout must not wait for it.
healthCheckExprs:
- apiVersion: cert-manager.io/v1
kind: ClusterIssuer
current: "true"