From 92d78d24de9b968d1ab293a4d0b5c33c47b8f9cf Mon Sep 17 00:00:00 2001 From: Myasnikov Daniil Date: Wed, 4 Nov 2026 12:50:23 +0500 Subject: [PATCH] fix(platform): do not gate cert-manager-issuers on ClusterIssuer readiness A ClusterIssuer turns Ready only after cert-manager has registered an ACME account with the CA. Under the kstatus wait helm-controller applies by default, an unreachable Let's Encrypt endpoint, staging included, keeps the cert-manager-issuers upgrade in progress until it times out. Every package that dependsOn cozystack.cert-manager then waits behind that release, so one unreachable CA leaves the platform half rolled out while the issuers that are in use keep issuing. Report the issuers as current through healthCheckExprs. The release completes once the manifests are applied, and the issuers recover on their own when the CA is reachable again. Assisted-by: LLM Signed-off-by: Myasnikov Daniil (cherry picked from commit 13fefcedda136b61ec9b5e29163574cb913d6746) Signed-off-by: cozystack-ci[bot] <274107086+cozystack-ci[bot]@users.noreply.github.com> --- internal/operator/package_reconciler_test.go | 46 +++++++++++++++++++ .../core/platform/sources/cert-manager.yaml | 9 ++++ 2 files changed, 55 insertions(+) diff --git a/internal/operator/package_reconciler_test.go b/internal/operator/package_reconciler_test.go index eaf7ba15f..143fd3ab3 100644 --- a/internal/operator/package_reconciler_test.go +++ b/internal/operator/package_reconciler_test.go @@ -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 { diff --git a/packages/core/platform/sources/cert-manager.yaml b/packages/core/platform/sources/cert-manager.yaml index 857e9a08e..731fa5aaf 100644 --- a/packages/core/platform/sources/cert-manager.yaml +++ b/packages/core/platform/sources/cert-manager.yaml @@ -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"