Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .ci/pipelines/cluster/gke/gcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
48 changes: 34 additions & 14 deletions .ci/pipelines/lib/operators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
zdrapela marked this conversation as resolved.
Resolved
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
}
5 changes: 5 additions & 0 deletions .ci/pipelines/resources/config_map/app-config-rhdh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
6 changes: 4 additions & 2 deletions e2e-tests/playwright/e2e/verify-redis-cache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
`,
},
{
Expand Down Expand Up @@ -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}`);
Expand Down
Loading