From 64e5bf9b0b08d383c377a49839ff7296caebf178 Mon Sep 17 00:00:00 2001 From: "frolov.so" Date: Sat, 26 Sep 2026 12:25:32 +0300 Subject: [PATCH 1/2] docs(api): clarify health check parsing and evaluation Health expressions are parsed before helm-controller selects a wait strategy, while evaluation also applies to hooks waited through the poller when install wait is disabled. The API documentation must distinguish these paths so future ApplicationDefinitions do not rely on invalid no-op assumptions. Fixes cozystack/cozystack#4388 Assisted-by: LLM Signed-off-by: frolov.so --- api/v1alpha1/applicationdefinitions_types.go | 12 ++++++++---- packages/extra/monitoring/templates/helmrelease.yaml | 12 +++++++----- .../cozystack.io_applicationdefinitions.yaml | 12 ++++++++---- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/api/v1alpha1/applicationdefinitions_types.go b/api/v1alpha1/applicationdefinitions_types.go index 0a6166254..98841a362 100644 --- a/api/v1alpha1/applicationdefinitions_types.go +++ b/api/v1alpha1/applicationdefinitions_types.go @@ -120,10 +120,14 @@ type ApplicationDefinitionRelease struct { // kstatus rules instead. // A CR whose CRD is not installed fails the Helm action before any wait, // whatever these expressions say. - // Upstream evaluates these only when the Helm action itself has wait - // enabled, so the release.cozystack.io/helm-install-disable-wait annotation - // makes them a silent no-op whatever waitStrategy says: the HelmRelease - // reports Ready as soon as helm applies the CR, with no error or warning. + // helm-controller parses and validates these expressions and constructs the + // status reader before choosing how to wait. Invalid configuration can + // therefore stall the HelmRelease with reason InvalidCELExpression even when + // the release.cozystack.io/helm-install-disable-wait annotation is set or the + // legacy wait strategy is selected. Once setup succeeds, only helm-controller's + // poller evaluates expressions: while a Helm action waits under the poller + // strategy, and for Helm hooks, which are still waited on when the annotation + // disables wait. The legacy strategy never evaluates them. // +optional HealthCheckExprs []kustomize.CustomHealthCheck `json:"healthCheckExprs,omitempty"` } diff --git a/packages/extra/monitoring/templates/helmrelease.yaml b/packages/extra/monitoring/templates/helmrelease.yaml index 0ffa7a630..42a67af26 100644 --- a/packages/extra/monitoring/templates/helmrelease.yaml +++ b/packages/extra/monitoring/templates/helmrelease.yaml @@ -43,11 +43,13 @@ spec: an unexpected status can never be silently read as Ready. A paused or failed log store is not ingesting, so the release must not report Ready; cozystack never sets spec.paused on these VLClusters, so `paused` is not - reachable in normal operation. Before the operator writes any updateStatus - (fresh apply) all three predicates are false, so the poller holds the - release not-ready until it becomes operational or hits `timeout:`, the - real backstop. Matching by kind covers every logsStorages entry. (CEL - evaluation is exercised live, not in helm-unittest, which cannot run it.) + reachable in normal operation. If status exists but has no updateStatus, + all three predicates evaluate to false. If the top-level status key is + absent, `has(status.updateStatus)` can instead fail during evaluation and + the status reader reports Unknown. The poller continues waiting in both + cases until the resource becomes operational or hits `timeout:`, the real + backstop. Matching by kind covers every logsStorages entry. (CEL evaluation + is exercised live, not in helm-unittest, which cannot run it.) The gate keys on a VLCluster existing, so an empty logsStorages would leave nothing to match. That configuration is rejected at render time by the diff --git a/packages/system/application-definition-crd/definition/cozystack.io_applicationdefinitions.yaml b/packages/system/application-definition-crd/definition/cozystack.io_applicationdefinitions.yaml index 9229e7601..f997f6398 100644 --- a/packages/system/application-definition-crd/definition/cozystack.io_applicationdefinitions.yaml +++ b/packages/system/application-definition-crd/definition/cozystack.io_applicationdefinitions.yaml @@ -337,10 +337,14 @@ spec: kstatus rules instead. A CR whose CRD is not installed fails the Helm action before any wait, whatever these expressions say. - Upstream evaluates these only when the Helm action itself has wait - enabled, so the release.cozystack.io/helm-install-disable-wait annotation - makes them a silent no-op whatever waitStrategy says: the HelmRelease - reports Ready as soon as helm applies the CR, with no error or warning. + helm-controller parses and validates these expressions and constructs the + status reader before choosing how to wait. Invalid configuration can + therefore stall the HelmRelease with reason InvalidCELExpression even when + the release.cozystack.io/helm-install-disable-wait annotation is set or the + legacy wait strategy is selected. Once setup succeeds, only helm-controller's + poller evaluates expressions: while a Helm action waits under the poller + strategy, and for Helm hooks, which are still waited on when the annotation + disables wait. The legacy strategy never evaluates them. items: description: CustomHealthCheck defines the health check for custom resources. From 05cdd323bbab1ed4db833d9ac467eed25fb0d512 Mon Sep 17 00:00:00 2001 From: "frolov.so" Date: Mon, 28 Sep 2026 18:46:01 +0300 Subject: [PATCH 2/2] docs(api): clarify legacy hook evaluation precedence Disabling install wait takes precedence over the selected wait strategy, so hook health expressions still run even when legacy is configured. State that exception explicitly so ApplicationDefinition authors do not assume their hook checks are bypassed. Assisted-by: LLM Signed-off-by: frolov.so --- api/v1alpha1/applicationdefinitions_types.go | 10 +++++++--- .../cozystack.io_applicationdefinitions.yaml | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/api/v1alpha1/applicationdefinitions_types.go b/api/v1alpha1/applicationdefinitions_types.go index 98841a362..82d5bd8de 100644 --- a/api/v1alpha1/applicationdefinitions_types.go +++ b/api/v1alpha1/applicationdefinitions_types.go @@ -120,14 +120,18 @@ type ApplicationDefinitionRelease struct { // kstatus rules instead. // A CR whose CRD is not installed fails the Helm action before any wait, // whatever these expressions say. - // helm-controller parses and validates these expressions and constructs the - // status reader before choosing how to wait. Invalid configuration can + // helm-controller parses and validates these expressions and creates a + // status reader factory before choosing how to wait. The factory constructs + // the concrete status reader when the selected wait path creates its + // resource manager. Invalid configuration can // therefore stall the HelmRelease with reason InvalidCELExpression even when // the release.cozystack.io/helm-install-disable-wait annotation is set or the // legacy wait strategy is selected. Once setup succeeds, only helm-controller's // poller evaluates expressions: while a Helm action waits under the poller // strategy, and for Helm hooks, which are still waited on when the annotation - // disables wait. The legacy strategy never evaluates them. + // disables wait. Without the annotation, the legacy strategy never evaluates + // them. With it, hooks are evaluated whatever the strategy, because disabling + // wait takes precedence. // +optional HealthCheckExprs []kustomize.CustomHealthCheck `json:"healthCheckExprs,omitempty"` } diff --git a/packages/system/application-definition-crd/definition/cozystack.io_applicationdefinitions.yaml b/packages/system/application-definition-crd/definition/cozystack.io_applicationdefinitions.yaml index f997f6398..8e208ac66 100644 --- a/packages/system/application-definition-crd/definition/cozystack.io_applicationdefinitions.yaml +++ b/packages/system/application-definition-crd/definition/cozystack.io_applicationdefinitions.yaml @@ -337,14 +337,18 @@ spec: kstatus rules instead. A CR whose CRD is not installed fails the Helm action before any wait, whatever these expressions say. - helm-controller parses and validates these expressions and constructs the - status reader before choosing how to wait. Invalid configuration can + helm-controller parses and validates these expressions and creates a + status reader factory before choosing how to wait. The factory constructs + the concrete status reader when the selected wait path creates its + resource manager. Invalid configuration can therefore stall the HelmRelease with reason InvalidCELExpression even when the release.cozystack.io/helm-install-disable-wait annotation is set or the legacy wait strategy is selected. Once setup succeeds, only helm-controller's poller evaluates expressions: while a Helm action waits under the poller strategy, and for Helm hooks, which are still waited on when the annotation - disables wait. The legacy strategy never evaluates them. + disables wait. Without the annotation, the legacy strategy never evaluates + them. With it, hooks are evaluated whatever the strategy, because disabling + wait takes precedence. items: description: CustomHealthCheck defines the health check for custom resources.