mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-01 12:46:14 +09:00
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>
(cherry picked from commit b74029cb39)
Signed-off-by: cozystack-ci[bot] <274107086+cozystack-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
cc86a0c4a0
commit
3a342b1e5f
4 files changed
+51
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
@@ -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)) \
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user