From 3b38ab2d7d892f498ce24ef7b68b3502bf36e930 Mon Sep 17 00:00:00 2001 From: Watson Yuuma Sato Date: Fri, 12 Sep 2025 14:46:44 +0200 Subject: [PATCH] Make CLO install channel change resilient Cluster Logging Operator keeps changing the list of available channels. On OCP version 4.19 stable-6.1 is not available anymore, while on 4.16 stable-6.3 is not available. This patch probes the operator manifest to grab the latest available channel and use that to install CLO. --- .../tests/ocp4/e2e-remediation.sh | 12 +++++------- .../tests/ocp4/e2e-remediation.sh | 6 ++++-- .../e2e/cluster-logging-install-observability.yaml | 2 +- ocp-resources/e2e/cluster-logging-install.yaml | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/applications/openshift/api-server/audit_log_forwarding_enabled/tests/ocp4/e2e-remediation.sh b/applications/openshift/api-server/audit_log_forwarding_enabled/tests/ocp4/e2e-remediation.sh index c3abb77af55a..239f8351d9a9 100755 --- a/applications/openshift/api-server/audit_log_forwarding_enabled/tests/ocp4/e2e-remediation.sh +++ b/applications/openshift/api-server/audit_log_forwarding_enabled/tests/ocp4/e2e-remediation.sh @@ -1,20 +1,18 @@ #!/bin/bash set -xe -ocp_version=$(oc version -ojson | jq -r '.openshiftVersion') -clo_v6_available_from="4.14.0" +export CLO_CHANNEL=$(oc get packagemanifest -o jsonpath='{range .status.channels[*]}{.name}{"\n"}{end}' -n openshift-marketplace cluster-logging | sort | tail -1) -if [ "$(printf '%s\n' "$ocp_version" "$clo_v6_available_from" | sort -V | head -n1)" = "$clo_v6_available_from" ]; then +if [ "${CLO_CHANNEL}" =~ stable-6\.* ]; then echo "OCP ${ocp_version} has CLO 6.0 is available for install"; install_v6=true fi +echo "installing cluster-logging-operator from channel ${CLO_CHANNEL}" if [ "$install_v6" = true ] ; then - echo "installing cluster-logging-operator V6.0" - oc apply -f ${ROOT_DIR}/ocp-resources/e2e/cluster-logging-install-observability.yaml + envsubst < <(cat ${ROOT_DIR}/ocp-resources/e2e/cluster-logging-install-observability.yaml) | oc apply -f else - echo "installing cluster-logging-operator" - oc apply -f ${ROOT_DIR}/ocp-resources/e2e/cluster-logging-install.yaml + envsusbst < <(cat ${ROOT_DIR}/ocp-resources/e2e/cluster-logging-install.yaml) | oc apply -f fi sleep 30 diff --git a/applications/openshift/api-server/audit_log_forwarding_enabled_logging_api/tests/ocp4/e2e-remediation.sh b/applications/openshift/api-server/audit_log_forwarding_enabled_logging_api/tests/ocp4/e2e-remediation.sh index db18099e3124..bad94d8bf92a 100755 --- a/applications/openshift/api-server/audit_log_forwarding_enabled_logging_api/tests/ocp4/e2e-remediation.sh +++ b/applications/openshift/api-server/audit_log_forwarding_enabled_logging_api/tests/ocp4/e2e-remediation.sh @@ -1,8 +1,10 @@ #!/bin/bash set -xe -echo "installing cluster-logging-operator" -oc apply -f ${ROOT_DIR}/ocp-resources/e2e/cluster-logging-install.yaml +export CLO_CHANNEL=$(oc get packagemanifest -o jsonpath='{range .status.channels[*]}{.name}{"\n"}{end}' -n openshift-marketplace cluster-logging | sort | tail -1) + +echo "installing cluster-logging-operator from channel ${CLO_CHANNEL}" +envsusbst < <(cat ${ROOT_DIR}/ocp-resources/e2e/cluster-logging-install.yaml) | oc apply -f sleep 30 diff --git a/ocp-resources/e2e/cluster-logging-install-observability.yaml b/ocp-resources/e2e/cluster-logging-install-observability.yaml index 61e1f90d5be5..90ceb36c2069 100644 --- a/ocp-resources/e2e/cluster-logging-install-observability.yaml +++ b/ocp-resources/e2e/cluster-logging-install-observability.yaml @@ -50,7 +50,7 @@ metadata: name: cluster-logging namespace: openshift-logging spec: - channel: stable-6.1 + channel: ${CLO_CHANNEL} name: cluster-logging source: redhat-operators sourceNamespace: openshift-marketplace diff --git a/ocp-resources/e2e/cluster-logging-install.yaml b/ocp-resources/e2e/cluster-logging-install.yaml index e39ae88b7ebf..ca47fd0e8ead 100644 --- a/ocp-resources/e2e/cluster-logging-install.yaml +++ b/ocp-resources/e2e/cluster-logging-install.yaml @@ -50,7 +50,7 @@ metadata: name: cluster-logging namespace: openshift-logging spec: - channel: stable + channel: ${CLO_CHANNEL} name: cluster-logging source: redhat-operators sourceNamespace: openshift-marketplace