Skip to content

Commit 09936aa

Browse files
committed
[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] openstack-k8s-operators/openstack-operator#1519 Signed-off-by: Yatin Karel <ykarel@redhat.com>
1 parent c0c67dd commit 09936aa

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

hack/run_with_local_webhook.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,14 @@ if [ -n "${CSV_NAME}" ]; then
235235
oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/install/spec/deployments/0/spec/replicas', 'value': 0}]"
236236
oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/webhookdefinitions', 'value': []}]"
237237
else
238-
# Handle operator deployed by Openstack Initialization resource
239-
CSV_NAME="$(oc get csv -n openstack-operators -l operators.coreos.com/openstack-operator.openstack-operators -o name)"
240-
241-
printf \
242-
"\n\tNow patching openstack operator CSV to scale down deployment resource.
243-
To restore it, use:
244-
oc patch "${CSV_NAME}" -n openstack-operators --type=json -p=\"[{'op': 'replace', 'path': '/spec/install/spec/deployments/0/spec/replicas', 'value': 1}]\""
238+
if CR_NAME=$(oc get openstack -n openstack-operators -o name); then
239+
printf \
240+
"\n\tNow patching openstack CR to scale down deployment resource.
241+
To restore it, use:
242+
oc patch ${CR_NAME} -n openstack-operators --type=merge -p \'{\"spec\": {\"operatorOverrides\": [{\"name\": \"ovn\", \"replicas\": 1}]}}\'\n"
245243

246-
oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/install/spec/deployments/0/spec/replicas', 'value': 0}]"
247-
oc scale --replicas=0 -n openstack-operators deploy/ovn-operator-controller-manager
244+
oc patch ${CR_NAME} -n openstack-operators --type=merge -p '{"spec": {"operatorOverrides": [{"name": "ovn", "replicas": 0}]}}'
245+
fi
248246
fi
249247

250248
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}"

0 commit comments

Comments
 (0)