From b74029cb390c79c1c7cf3a1a697e0f6b70d353d1 Mon Sep 17 00:00:00 2001 From: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> Date: Sun, 18 Oct 2026 23:11:02 +0300 Subject: [PATCH 1/2] fix(keycloak): apply keycloak-operator CRD updates on upgrade keycloak-operator ships its CRDs in the chart's crds/ directory and its PackageSource sets no upgradeCRDs policy, so helm-controller never replaces them. A cluster installed before v1.2.0 therefore runs the v1.32.0 operator against the v1.25.0 CRDs, whose ClusterKeycloakRealm schema has no spec.sessions, spec.login or spec.organizationsEnabled. The apiserver drops those fields from the realm keycloak-configure renders, so the operator never applies the session limits the platform sets. On a v1.6.4 cluster in that state Keycloak also rejected the dashboard client with HTTP 400, and replacing the CRDs from the chart by hand, with an operator restart, cleared it. The v1.32.0 CRDs are not purely additive. They drop the realm, targetRealm and keycloakOwner fields that v1.25.0 marked deprecated and require realmRef and keycloakRef instead. Every Keycloak object the platform renders already uses the refs, and each CRD keeps its single version, so replacing them loses nothing the platform relies on. helm-controller applies the policy only when it upgrades the release, and it runs an upgrade only when the release artifact or its values change, which a PackageSource edit does not do. The package test added here also changes the keycloak-operator artifact, so the replace runs on the upgrade that ships this change even where nothing else in the package changes. The test itself pins the realm fields keycloak-configure sets against the CRD the chart ships. Assisted-by: LLM Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> --- .../platform/sources/keycloak-operator.yaml | 7 ++++++ .../sources_keycloak_operator_crds_test.yaml | 22 +++++++++++++++++++ packages/system/keycloak-operator/Makefile | 3 +++ .../keycloak-operator/tests/crds_test.yaml | 19 ++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 packages/core/platform/tests/sources_keycloak_operator_crds_test.yaml create mode 100644 packages/system/keycloak-operator/tests/crds_test.yaml diff --git a/packages/core/platform/sources/keycloak-operator.yaml b/packages/core/platform/sources/keycloak-operator.yaml index ce3a5f7e0..5b116e5e6 100644 --- a/packages/core/platform/sources/keycloak-operator.yaml +++ b/packages/core/platform/sources/keycloak-operator.yaml @@ -20,3 +20,10 @@ spec: install: namespace: cozy-keycloak releaseName: keycloak-operator + # helm-controller leaves existing CRDs alone on upgrade, so a cluster + # installed before v1.2.0 keeps the v1.25.0 schema and the apiserver + # prunes the realm session settings keycloak-configure sets. v1.32.0 + # drops the realm, targetRealm and keycloakOwner fields deprecated in + # favour of realmRef and keycloakRef. The platform renders only the + # refs, so replace is safe. + upgradeCRDs: CreateReplace diff --git a/packages/core/platform/tests/sources_keycloak_operator_crds_test.yaml b/packages/core/platform/tests/sources_keycloak_operator_crds_test.yaml new file mode 100644 index 000000000..5cccfc757 --- /dev/null +++ b/packages/core/platform/tests/sources_keycloak_operator_crds_test.yaml @@ -0,0 +1,22 @@ +suite: keycloak-operator applies CRD updates on upgrade +# keycloak-configure sets spec.sessions and spec.organizationsEnabled, and +# spec.login when configured, on the cozy ClusterKeycloakRealm. The CRDs of +# keycloak-operator v1.25.0 declare none of them. Helm never upgrades CRDs +# shipped in crds/, so without CreateReplace a cluster installed before v1.2.0 +# keeps those CRDs, the apiserver drops the fields without an error, and the +# operator never applies them to the realm. Pin the policy so an upgrade cannot +# silently regress. +templates: + - templates/sources.yaml +release: + name: cozystack + namespace: cozy-system +tests: + - it: keycloak-operator PackageSource sets upgradeCRDs to CreateReplace + documentSelector: + path: metadata.name + value: cozystack.keycloak-operator + asserts: + - equal: + path: spec.variants[0].components[0].install.upgradeCRDs + value: CreateReplace diff --git a/packages/system/keycloak-operator/Makefile b/packages/system/keycloak-operator/Makefile index e2f7f45d5..303f37eeb 100644 --- a/packages/system/keycloak-operator/Makefile +++ b/packages/system/keycloak-operator/Makefile @@ -4,6 +4,9 @@ export NAMESPACE=cozy-keycloak include ../../../hack/common-envs.mk include ../../../hack/package.mk +test: + helm unittest . + image: docker buildx build images/keycloak-operator \ $(call image-tags,keycloak-operator,v$(COZYSTACK_VERSION)) \ diff --git a/packages/system/keycloak-operator/tests/crds_test.yaml b/packages/system/keycloak-operator/tests/crds_test.yaml new file mode 100644 index 000000000..1be3fe611 --- /dev/null +++ b/packages/system/keycloak-operator/tests/crds_test.yaml @@ -0,0 +1,19 @@ +suite: keycloak-operator CRDs declare the realm settings the platform sets +# keycloak-configure renders the cozy ClusterKeycloakRealm with spec.sessions +# and spec.organizationsEnabled, and spec.login when configured. The apiserver +# drops any field the CRD does not declare without an error, so with a chart +# that lacks them the realm never gets those settings. +includeCrds: true +templates: + - charts/keycloak-operator/crds/v1.edp.epam.com_clusterkeycloakrealms.yaml +tests: + - it: declares the session, organization and login settings + asserts: + - exists: + path: spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.sessions.properties.ssoSessionSettings.properties.idleTimeout + - exists: + path: spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.sessions.properties.ssoSessionSettings.properties.maxLifespan + - exists: + path: spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.organizationsEnabled + - exists: + path: spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.login From 8e96a3e9b73b127a116131327b73925e7c2ffa9a Mon Sep 17 00:00:00 2001 From: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> Date: Sun, 18 Oct 2026 22:59:52 +0300 Subject: [PATCH 2/2] fix(foundationdb): apply foundationdb-operator CRD updates on upgrade The foundationdb-operator PackageSource sets no upgradeCRDs policy, so a cluster installed before v1.6.0 runs the v2.30.0 operator on the v2.13.0 CRDs it first installed. The apiserver prunes every field added since, status.backupDetails.restorable on FoundationDBBackup among them, so a backup never shows as restorable however long it has run. The v2.30.0 CRDs only add fields. They keep the single v1beta2 version and drop or retype nothing, and the one new constraint, a pattern on perpetual_storage_wiggle_locality, sits on a field the platform does not set, so CreateReplace is safe. Nothing in the foundationdb-operator package changes here, so a cluster picks the new CRDs up at the next upgrade of that release, which comes with the next change to the package. Assisted-by: LLM Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> --- .../sources/foundationdb-operator.yaml | 6 ++++++ ...urces_foundationdb_operator_crds_test.yaml | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 packages/core/platform/tests/sources_foundationdb_operator_crds_test.yaml diff --git a/packages/core/platform/sources/foundationdb-operator.yaml b/packages/core/platform/sources/foundationdb-operator.yaml index 0af881f60..28328c3d1 100644 --- a/packages/core/platform/sources/foundationdb-operator.yaml +++ b/packages/core/platform/sources/foundationdb-operator.yaml @@ -20,3 +20,9 @@ spec: install: namespace: cozy-foundationdb-operator releaseName: foundationdb-operator + # helm-controller leaves existing CRDs alone on upgrade, so a cluster + # installed before v1.6.0 keeps the v2.13.0 schema under the v2.30.0 + # operator, and the apiserver prunes the fields added since, + # status.backupDetails.restorable among them. The schema diff adds + # fields and drops none, so replace is safe. + upgradeCRDs: CreateReplace diff --git a/packages/core/platform/tests/sources_foundationdb_operator_crds_test.yaml b/packages/core/platform/tests/sources_foundationdb_operator_crds_test.yaml new file mode 100644 index 000000000..a0976ae57 --- /dev/null +++ b/packages/core/platform/tests/sources_foundationdb_operator_crds_test.yaml @@ -0,0 +1,20 @@ +suite: foundationdb-operator applies CRD updates on upgrade +# The fdb-operator v2.30.0 CRDs add fields the v2.13.0 ones lack, among them +# status.backupDetails.restorable on FoundationDBBackup. Helm never upgrades +# CRDs shipped in crds/, so without CreateReplace a cluster installed before +# v1.6.0 keeps the v2.13.0 CRDs and the apiserver prunes those fields on every +# write. Pin the policy so an upgrade cannot silently regress. +templates: + - templates/sources.yaml +release: + name: cozystack + namespace: cozy-system +tests: + - it: foundationdb-operator PackageSource sets upgradeCRDs to CreateReplace + documentSelector: + path: metadata.name + value: cozystack.foundationdb-operator + asserts: + - equal: + path: spec.variants[0].components[0].install.upgradeCRDs + value: CreateReplace