From 65b3a9a40cc97b0e093d734024aa5c6843c96159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Fri, 4 Dec 2026 14:42:56 +0100 Subject: [PATCH 1/3] fix(ci): repair OLM on the shared GKE cluster and keep it installed The GKE nightlies share one long-lived cluster and its cluster-scoped OLM installation. A cleanup that failed after a partial uninstall left OLM unusable, and every Operator job then failed on "detected existing OLM resources" until the cluster was repaired by hand. - Detect OLM from its deployments instead of `operator-sdk olm status`, which fetches the release manifests and fails on a partial installation. - Remove OLM by name in OLM's documented uninstall order before installing, and retry, so a partial installation repairs itself instead of failing the job forever. - Keep OLM installed on the long-lived cluster; cleanup now removes the RHDH CatalogSource and the OLM-owned RBAC of the deleted operator namespace and logs failures instead of aborting the rest of the trap. - Restore `techdocs.cache.ttl`: TechDocs only creates its cache when that key is set, so without it no `techdocs` keys reach Redis and the cache test cannot pass (RHDHBUGS-3762). - Log the Redis DBSIZE and techdocs keys in that test, and `exec` its port-forward so stopping the session also stops `kubectl`; Playwright retries used to fail with "address already in use". Jira: https://redhat.atlassian.net/browse/RHDHBUGS-4181 Assisted-by: OpenCode --- .ci/pipelines/cluster/gke/gcloud.sh | 14 ++++-- .ci/pipelines/lib/operators.sh | 48 +++++++++++++------ .../resources/config_map/app-config-rhdh.yaml | 5 ++ .../playwright/e2e/verify-redis-cache.spec.ts | 6 ++- 4 files changed, 54 insertions(+), 19 deletions(-) diff --git a/.ci/pipelines/cluster/gke/gcloud.sh b/.ci/pipelines/cluster/gke/gcloud.sh index f2b773f73e..cd7a509f1c 100755 --- a/.ci/pipelines/cluster/gke/gcloud.sh +++ b/.ci/pipelines/cluster/gke/gcloud.sh @@ -37,8 +37,16 @@ gcloud_ssl_cert_create() { } cleanup_gke() { - uninstall_olm - delete_rhdh_operator + # OLM stays installed on the long-lived cluster; each deployment removes the + # RHDH operator it created. Failures must not abort the remaining steps. + delete_rhdh_operator || log::warn "Failed to delete the RHDH operator during cleanup." + # The RHDH CatalogSource points at the registry inside the operator namespace. + kubectl get catalogsource --namespace=olm -o name 2> /dev/null \ + | grep '/rhdh-' | xargs -r kubectl delete --namespace=olm --ignore-not-found \ + || log::warn "Failed to delete the RHDH CatalogSource during cleanup." + kubectl delete clusterrole,clusterrolebinding \ + -l "olm.owner.namespace=${OPERATOR_MANAGER:-rhdh-operator}" --ignore-not-found \ + || log::warn "Failed to delete OLM-owned RBAC for the RHDH operator." # The GKE cluster is long-lived; release the Keycloak load balancer. - keycloak::delete + keycloak::delete || log::warn "Failed to delete Keycloak during cleanup." } diff --git a/.ci/pipelines/lib/operators.sh b/.ci/pipelines/lib/operators.sh index f14b830445..245ed7845e 100644 --- a/.ci/pipelines/lib/operators.sh +++ b/.ci/pipelines/lib/operators.sh @@ -27,26 +27,46 @@ operator::install_tekton() { return 0 } -# Install Operator Lifecycle Manager if not present -operator::install_olm() { - if operator-sdk olm status > /dev/null 2>&1; then - log::info "OLM is already installed." +# `operator-sdk olm status` fetches the release manifests and fails on a partial +# installation, which used to leave the shared GKE cluster unusable. +operator::olm_healthy() { + kubectl wait deployment/olm-operator deployment/catalog-operator deployment/packageserver \ + --namespace=olm --for=condition=Available --timeout=120s > /dev/null 2>&1 +} + +# `operator-sdk olm uninstall` resolves resources from its manifest and leftovers +# of a partial installation break it; the names below are OLM's cluster-scoped +# resources, in OLM's documented uninstall order. +operator::uninstall_olm() { + if [[ "${IS_OPENSHIFT:-}" == "true" ]]; then + log::warn "OLM is managed by the platform on OpenShift; not removing it." return 0 fi - log::info "OLM is not installed. Installing..." - operator-sdk olm install - return $? + log::info "Removing OLM resources" + # Stop the operators first, otherwise they recreate the APIService after it is deleted. + kubectl delete deployment olm-operator catalog-operator packageserver \ + --namespace=olm --ignore-not-found --cascade=foreground --timeout=120s || return 1 + kubectl delete apiservice v1.packages.operators.coreos.com --ignore-not-found || return 1 + kubectl get crd -o name | grep '\.operators\.coreos\.com$' | xargs -r kubectl delete --timeout=120s || return 1 + kubectl delete clusterrolebinding olm-operator-binding-olm --ignore-not-found || return 1 + kubectl delete clusterrole aggregate-olm-edit aggregate-olm-view \ + system:controller:operator-lifecycle-manager --ignore-not-found || return 1 + kubectl delete namespace olm operators --ignore-not-found --timeout=300s } -# Uninstall Operator Lifecycle Manager if present -operator::uninstall_olm() { - if operator-sdk olm status > /dev/null 2>&1; then - log::info "OLM is installed. Uninstalling..." - operator-sdk olm uninstall +# `operator-sdk olm install` refuses to run over resources left by a failed attempt. +operator::reinstall_olm() { + operator::uninstall_olm \ + && operator-sdk olm install --timeout=5m +} + +operator::install_olm() { + if operator::olm_healthy; then + log::info "OLM is already installed." return 0 fi - log::info "OLM is not installed. Nothing to uninstall." - return 0 + log::info "Installing OLM..." + common::retry 3 30 operator::reinstall_olm } diff --git a/.ci/pipelines/resources/config_map/app-config-rhdh.yaml b/.ci/pipelines/resources/config_map/app-config-rhdh.yaml index 012e6e1457..e228d44316 100644 --- a/.ci/pipelines/resources/config_map/app-config-rhdh.yaml +++ b/.ci/pipelines/resources/config_map/app-config-rhdh.yaml @@ -111,6 +111,11 @@ auth: signInPage: - guest - oidc +techdocs: + cache: + # TechDocs only creates its cache when this key is set; without it no + # techdocs keys are written to Redis and the cache test cannot pass. + ttl: 3600000 proxy: skipInvalidProxies: true # endpoints: {} diff --git a/e2e-tests/playwright/e2e/verify-redis-cache.spec.ts b/e2e-tests/playwright/e2e/verify-redis-cache.spec.ts index 214ce7d66b..df4d3f54f1 100644 --- a/e2e-tests/playwright/e2e/verify-redis-cache.spec.ts +++ b/e2e-tests/playwright/e2e/verify-redis-cache.spec.ts @@ -25,7 +25,7 @@ test.describe("Verify Redis Cache DB", () => { shellCommand: ` oc login --token="${process.env.K8S_CLUSTER_TOKEN}" --server="${process.env.K8S_CLUSTER_URL}" --insecure-skip-tls-verify=true && kubectl config set-context --current --namespace="${process.env.NAME_SPACE}" && - kubectl port-forward service/redis ${REDIS_LOCAL_PORT}:6379 --namespace="${process.env.NAME_SPACE}" + exec kubectl port-forward service/redis ${REDIS_LOCAL_PORT}:6379 --namespace="${process.env.NAME_SPACE}" `, }, { @@ -63,7 +63,9 @@ test.describe("Verify Redis Cache DB", () => { ); console.log("Verifying Redis keys..."); await expect(async () => { - const keys = (await redis.keys("*")).filter((k) => k.includes("techdocs")); + const allKeys = await redis.keys("*"); + const keys = allKeys.filter((k) => k.includes("techdocs")); + console.log(`Redis DBSIZE: ${allKeys.length}, techdocs keys: ${keys.join(", ")}`); expect(keys).toContainEqual(expect.stringContaining("techdocs")); const key = keys[0]; console.log(`Verifying key format: ${key}`); From 2dabf27c67771304e192ad7eafbf4a1e3969c233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Fri, 4 Dec 2026 16:13:45 +0100 Subject: [PATCH 2/3] fix(ci): strip the CSV finalizer before removing the OLM CRDs OLM 0.28 puts the operators.coreos.com/csv-cleanup finalizer on every CSV and only olm-operator removes it. The repair stops olm-operator first, so deleting the CSV CRD left it Terminating, the delete timed out and every retry failed on the same stuck CRD. Also drop the claim that the removal follows OLM's documented order: upstream deletes the CSVs while olm-operator is still running. Assisted-by: OpenCode --- .ci/pipelines/lib/operators.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.ci/pipelines/lib/operators.sh b/.ci/pipelines/lib/operators.sh index 245ed7845e..3f3fb47210 100644 --- a/.ci/pipelines/lib/operators.sh +++ b/.ci/pipelines/lib/operators.sh @@ -35,8 +35,8 @@ operator::olm_healthy() { } # `operator-sdk olm uninstall` resolves resources from its manifest and leftovers -# of a partial installation break it; the names below are OLM's cluster-scoped -# resources, in OLM's documented uninstall order. +# of a partial installation break it, so OLM's cluster-scoped resources are +# removed by name instead. operator::uninstall_olm() { if [[ "${IS_OPENSHIFT:-}" == "true" ]]; then log::warn "OLM is managed by the platform on OpenShift; not removing it." @@ -48,6 +48,12 @@ operator::uninstall_olm() { kubectl delete deployment olm-operator catalog-operator packageserver \ --namespace=olm --ignore-not-found --cascade=foreground --timeout=120s || return 1 kubectl delete apiservice v1.packages.operators.coreos.com --ignore-not-found || return 1 + # olm-operator is gone, so nothing else removes the finalizer it puts on every CSV. + kubectl get csv --all-namespaces \ + -o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}' 2> /dev/null \ + | while read -r ns name; do + kubectl patch csv "${name}" --namespace="${ns}" --type=merge -p '{"metadata":{"finalizers":null}}' + done kubectl get crd -o name | grep '\.operators\.coreos\.com$' | xargs -r kubectl delete --timeout=120s || return 1 kubectl delete clusterrolebinding olm-operator-binding-olm --ignore-not-found || return 1 kubectl delete clusterrole aggregate-olm-edit aggregate-olm-view \ From ef8a73fbd1134c089302fb0807f7813655fd3a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Fri, 4 Dec 2026 16:26:10 +0100 Subject: [PATCH 3/3] fix(ci): check OLM's APIs and clean up after its CSV finalizer `operator-sdk olm uninstall`, which the release branches still run on the shared GKE cluster, deletes the CRDs before the deployments. An interrupted uninstall left the deployments Available without the APIs, so the health check skipped the repair. It now also requires the core OLM CRDs and the packages APIService. Stripping the csv-cleanup finalizer skipped what it does: delete the ClusterRoles, ClusterRoleBindings and webhook configurations OLM created for the CSV. Delete them by their owner label instead of orphaning them. Assisted-by: OpenCode --- .ci/pipelines/lib/operators.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.ci/pipelines/lib/operators.sh b/.ci/pipelines/lib/operators.sh index 3f3fb47210..8b0144251d 100644 --- a/.ci/pipelines/lib/operators.sh +++ b/.ci/pipelines/lib/operators.sh @@ -29,9 +29,16 @@ operator::install_tekton() { # `operator-sdk olm status` fetches the release manifests and fails on a partial # installation, which used to leave the shared GKE cluster unusable. +# `operator-sdk olm uninstall` deletes the CRDs before the deployments, so an +# interrupted uninstall leaves the deployments Available without OLM's APIs. operator::olm_healthy() { kubectl wait deployment/olm-operator deployment/catalog-operator deployment/packageserver \ - --namespace=olm --for=condition=Available --timeout=120s > /dev/null 2>&1 + --namespace=olm --for=condition=Available --timeout=120s > /dev/null 2>&1 || return 1 + kubectl wait crd/catalogsources.operators.coreos.com crd/clusterserviceversions.operators.coreos.com \ + crd/installplans.operators.coreos.com crd/operatorgroups.operators.coreos.com \ + crd/subscriptions.operators.coreos.com --for=condition=Established --timeout=30s > /dev/null 2>&1 || return 1 + kubectl wait apiservice/v1.packages.operators.coreos.com \ + --for=condition=Available --timeout=60s > /dev/null 2>&1 } # `operator-sdk olm uninstall` resolves resources from its manifest and leftovers @@ -54,6 +61,9 @@ operator::uninstall_olm() { | while read -r ns name; do kubectl patch csv "${name}" --namespace="${ns}" --type=merge -p '{"metadata":{"finalizers":null}}' done + # The cluster-scoped resources that finalizer deletes for its CSV. + kubectl delete clusterrole,clusterrolebinding,mutatingwebhookconfiguration,validatingwebhookconfiguration \ + -l olm.owner.kind=ClusterServiceVersion --ignore-not-found || return 1 kubectl get crd -o name | grep '\.operators\.coreos\.com$' | xargs -r kubectl delete --timeout=120s || return 1 kubectl delete clusterrolebinding olm-operator-binding-olm --ignore-not-found || return 1 kubectl delete clusterrole aggregate-olm-edit aggregate-olm-view \