From 09936aa93f1ddacec18b1ac5269a1fa04726f2fd Mon Sep 17 00:00:00 2001 From: Yatin Karel Date: Wed, 8 Apr 2026 18:05:58 +0530 Subject: [PATCH] [run-with-webhook] use openstack CR to scale down operator With [1] we can avoid disabling openstack init operator and just scale down the operators as needed, let's use it with run with webhook. [1] https://github.com/openstack-k8s-operators/openstack-operator/pull/1519 Signed-off-by: Yatin Karel --- hack/run_with_local_webhook.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hack/run_with_local_webhook.sh b/hack/run_with_local_webhook.sh index b36e8845..094c87a5 100755 --- a/hack/run_with_local_webhook.sh +++ b/hack/run_with_local_webhook.sh @@ -235,16 +235,14 @@ if [ -n "${CSV_NAME}" ]; then oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/install/spec/deployments/0/spec/replicas', 'value': 0}]" oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/webhookdefinitions', 'value': []}]" else - # Handle operator deployed by Openstack Initialization resource - CSV_NAME="$(oc get csv -n openstack-operators -l operators.coreos.com/openstack-operator.openstack-operators -o name)" - - printf \ - "\n\tNow patching openstack operator CSV to scale down deployment resource. - To restore it, use: - oc patch "${CSV_NAME}" -n openstack-operators --type=json -p=\"[{'op': 'replace', 'path': '/spec/install/spec/deployments/0/spec/replicas', 'value': 1}]\"" + if CR_NAME=$(oc get openstack -n openstack-operators -o name); then + printf \ + "\n\tNow patching openstack CR to scale down deployment resource. + To restore it, use: + oc patch ${CR_NAME} -n openstack-operators --type=merge -p \'{\"spec\": {\"operatorOverrides\": [{\"name\": \"ovn\", \"replicas\": 1}]}}\'\n" - oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/install/spec/deployments/0/spec/replicas', 'value': 0}]" - oc scale --replicas=0 -n openstack-operators deploy/ovn-operator-controller-manager + oc patch ${CR_NAME} -n openstack-operators --type=merge -p '{"spec": {"operatorOverrides": [{"name": "ovn", "replicas": 0}]}}' + fi fi go run ./cmd/main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}" -webhook-bind-address "${WEBHOOK_PORT}"