From 2fa86ba4858a1a46c0b1fb6ae2dc4da07d2bc51d Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Wed, 17 Dec 2025 17:55:03 +0100 Subject: [PATCH 1/2] fix(e2e): use Subscription config for OLM environment variables Replace CSV patching with the proper OLM Subscription configuration mechanism for setting POSTGRES_IMAGE_NAME and PGBOUNCER_IMAGE_NAME environment variables. The new approach uses spec.config.env in the Subscription resource, which OLM automatically applies to all containers in the operator pod. Closes #9482 Signed-off-by: Marco Nenciarini --- hack/e2e/run-e2e-ocp.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hack/e2e/run-e2e-ocp.sh b/hack/e2e/run-e2e-ocp.sh index d6b5a5ded0..72e8721661 100755 --- a/hack/e2e/run-e2e-ocp.sh +++ b/hack/e2e/run-e2e-ocp.sh @@ -110,6 +110,12 @@ spec: name: cloudnative-pg source: cloudnative-pg-catalog sourceNamespace: openshift-marketplace + config: + env: + - name: POSTGRES_IMAGE_NAME + value: ${POSTGRES_IMG} + - name: PGBOUNCER_IMAGE_NAME + value: ${PGBOUNCER_IMG} EOF # The subscription will install the operator, but the service account used @@ -127,20 +133,13 @@ CSV_NAME=$(oc get csv -n openshift-operators -l 'operators.coreos.com/cloudnativ DEPLOYMENT_NAME=$(oc get csv -n openshift-operators "$CSV_NAME" -o jsonpath='{.spec.install.spec.deployments[0].name}') wait_for deployment openshift-operators "$DEPLOYMENT_NAME" 5 60 -# Force a default postgresql and pgbouncer image in the running operator -oc patch -n openshift-operators csv "$CSV_NAME" --type='json' -p \ -"[ - {\"op\": \"add\", \"path\": \"/spec/install/spec/deployments/0/spec/template/spec/containers/0/env/0\", \"value\": { \"name\": \"POSTGRES_IMAGE_NAME\", \"value\": \"${POSTGRES_IMG}\"}}, - {\"op\": \"add\", \"path\": \"/spec/install/spec/deployments/0/spec/template/spec/containers/0/env/1\", \"value\": { \"name\": \"PGBOUNCER_IMAGE_NAME\", \"value\": \"${PGBOUNCER_IMG}\"}} -]" - -# After patching, we need some time to propagate the change to the deployment and the pod. +# After creating Subscription, OLM needs time to create and start the operator pod with the configured environment ITER=0 while true; do ITER=$((ITER + 1)) sleep 5 if [[ $ITER -gt 60 ]]; then - echo "Patch not propagated to pod, exiting" + echo "OLM did not create operator pod with correct environment, exiting" oc get -n openshift-operators "$(oc get -n openshift-operators deployments -o name)" -o yaml || true oc get -n openshift-operators "$(oc get -n openshift-operators pods -o name)" -o yaml || true oc logs -n openshift-operators "$(oc get -n openshift-operators pods -o name)" || true From a8eea529f566098fd327ece6ecc3be8c5c5b6f3c Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Wed, 17 Dec 2025 18:57:56 +0100 Subject: [PATCH 2/2] chore: move STANDBY_TCP_USER_TIMEOUT to Subscription config Remove the configmap-based approach for setting STANDBY_TCP_USER_TIMEOUT and instead configure it through the Subscription env config for consistency with other environment variables. Signed-off-by: Marco Nenciarini --- hack/e2e/run-e2e-ocp.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hack/e2e/run-e2e-ocp.sh b/hack/e2e/run-e2e-ocp.sh index 72e8721661..ea36b05804 100755 --- a/hack/e2e/run-e2e-ocp.sh +++ b/hack/e2e/run-e2e-ocp.sh @@ -95,9 +95,6 @@ oc apply -f cloudnative-pg-catalog.yaml # create the secret for the index to be pulled in the marketplace oc create secret docker-registry -n openshift-marketplace --docker-server="${REGISTRY}" --docker-username="${REGISTRY_USER}" --docker-password="${REGISTRY_PASSWORD}" cnpg-pull-secret || true -# Create the default configmap to set global keepalives on all the tests -oc create configmap -n openshift-operators --from-literal=STANDBY_TCP_USER_TIMEOUT=5000 cnpg-controller-manager-config - # Install the operator oc apply -f - <