From 2ea8a25aa071117ae577301bb3d13c7298d8f35c Mon Sep 17 00:00:00 2001 From: rostalan Date: Thu, 9 Apr 2026 13:27:30 +0200 Subject: [PATCH] fix: orchestrator install fixes - startingCSV, OLM status checks - Replace check_operator_status with OLM label-based wait_for_operator: spec.displayName varies across channels/versions, causing empty CSV matches and operator timeouts. Uses deterministic operators.coreos.com/. label selectors instead. - Add startingCSV pinning to logic-operator.v1.37.2: Ensures the subscription installs the exact OSL version instead of whatever stable channel resolves to. - Add prepack lifecycle script: Ensures dist/ is built when the package is installed as a git dependency. Made-with: Cursor --- docs/changelog.md | 10 ++++- package.json | 2 +- .../orchestrator/install-orchestrator.sh | 38 +++++++++++-------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index edf7148..bf7ced9 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,7 +2,15 @@ All notable changes to this project will be documented in this file. -## [1.1.30] - Current +## [1.1.31] - Current + +### Fixed + +- **Replace `check_operator_status` with OLM label-based `wait_for_operator`**: `spec.displayName` varies across channels/versions, causing empty CSV matches and operator timeouts. Uses deterministic `operators.coreos.com/.` label selectors instead. +- **Add `startingCSV` pinning to `logic-operator.v1.37.2`**: Ensures the subscription installs the exact OSL version instead of whatever `stable` channel resolves to. +- **Add `prepack` lifecycle script**: Ensures `dist/` is built when the package is installed as a git dependency (Yarn 3 packs from source, skipping gitignored `dist/`). + +## [1.1.30] ### Fixed diff --git a/package.json b/package.json index 0c4f23f..88a80e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@red-hat-developer-hub/e2e-test-utils", - "version": "1.1.30", + "version": "1.1.31", "description": "Test utilities for RHDH E2E tests", "license": "Apache-2.0", "repository": { diff --git a/src/deployment/orchestrator/install-orchestrator.sh b/src/deployment/orchestrator/install-orchestrator.sh index 94e347d..ebf2b57 100755 --- a/src/deployment/orchestrator/install-orchestrator.sh +++ b/src/deployment/orchestrator/install-orchestrator.sh @@ -105,9 +105,9 @@ log::success() { # Operator subscription and status # --------------------------------------------------------------------------- install_subscription() { - local name=$1 namespace=$2 channel=$3 package=$4 source_name=$5 source_namespace=$6 - oc apply -f - << EOD -apiVersion: operators.coreos.com/v1alpha1 + local name=$1 namespace=$2 channel=$3 package=$4 source_name=$5 source_namespace=$6 starting_csv=${7:-} + local yaml + yaml="apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: $name @@ -117,30 +117,38 @@ spec: installPlanApproval: Automatic name: $package source: $source_name - sourceNamespace: $source_namespace -EOD + sourceNamespace: $source_namespace" + if [[ -n "$starting_csv" ]]; then + yaml+=" + startingCSV: $starting_csv" + fi + echo "$yaml" | oc apply -f - return 0 } -check_operator_status() { - local timeout=${1:-300} namespace=$2 operator_name=$3 expected_status=${4:-Succeeded} - log::info "Checking operator '${operator_name}' in '${namespace}' (timeout ${timeout}s, expected: ${expected_status})" +# Wait for an operator CSV to reach a status phase. +# Uses OLM label selector (operators.coreos.com/.) which is +# deterministic, unlike spec.displayName which varies across channels/versions. +wait_for_operator() { + local timeout=${1:-300} namespace=$2 package=$3 expected_status=${4:-Succeeded} + local label="operators.coreos.com/${package}.${namespace}" + log::info "Waiting for operator '${package}' in '${namespace}' (label=${label}, timeout ${timeout}s, expected: ${expected_status})" timeout "${timeout}" bash -c " while true; do - CURRENT_PHASE=\$(oc get csv -n '${namespace}' -o jsonpath='{.items[?(@.spec.displayName==\"${operator_name}\")].status.phase}') - echo \"[check_operator_status] Phase: \${CURRENT_PHASE}\" >&2 - [[ \"\${CURRENT_PHASE}\" == \"${expected_status}\" ]] && echo \"[check_operator_status] Operator reached ${expected_status}\" >&2 && break + CURRENT_PHASE=\$(oc get csv -n '${namespace}' -l '${label}' -o jsonpath='{.items[0].status.phase}' 2>/dev/null) + echo \"[wait_for_operator] Phase: \${CURRENT_PHASE}\" >&2 + [[ \"\${CURRENT_PHASE}\" == \"${expected_status}\" ]] && echo \"[wait_for_operator] Operator reached ${expected_status}\" >&2 && break sleep 10 done - " || { log::error "Operator did not reach ${expected_status} in time."; return 1; } + " || { log::error "Operator '${package}' did not reach ${expected_status} in time."; return 1; } } install_serverless_logic_ocp_operator() { - install_subscription logic-operator openshift-operators stable logic-operator redhat-operators openshift-marketplace + install_subscription logic-operator openshift-operators stable logic-operator redhat-operators openshift-marketplace logic-operator.v1.37.2 return 0 } waitfor_serverless_logic_ocp_operator() { - check_operator_status 500 openshift-operators "Red Hat OpenShift Serverless Logic" Succeeded + wait_for_operator 500 openshift-operators logic-operator Succeeded return 0 } @@ -149,7 +157,7 @@ install_serverless_ocp_operator() { return 0 } waitfor_serverless_ocp_operator() { - check_operator_status 300 openshift-operators "Red Hat OpenShift Serverless" Succeeded + wait_for_operator 300 openshift-operators serverless-operator Succeeded return 0 }