From 80909504fb52ded265861a3f2af3f9b49c0507d3 Mon Sep 17 00:00:00 2001 From: Andrew Bays Date: Mon, 14 Oct 2024 11:44:34 +0000 Subject: [PATCH] Remove OLM webhooks when running 'make run-with-webhook', part 2 --- Makefile | 11 +++++------ hack/configure_local_webhook.sh | 8 +++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 9b8641c..9c9d53a 100644 --- a/Makefile +++ b/Makefile @@ -353,12 +353,11 @@ tidy: ## Run go mod tidy on every mod file in the repo cd ./api && go mod tidy # Used for webhook testing -# Please ensure the horizon-controller-manager deployment and -# webhook definitions are removed from the csv before running -# this. Also, cleanup the webhook configuration for local testing -# before deplying with olm again. -# $oc delete -n openstack validatingwebhookconfiguration/vhorizon.kb.io -# $oc delete -n openstack mutatingwebhookconfiguration/mhorizon.kb.io +# The configure_local_webhooks.sh script below will remove any OLM webhooks +# for the operator and also scale its deployment replicas down to 0 so that +# the operator can run locally. +# Make sure to cleanup the webhook configuration for local testing by running +# ./hack/clean_local_webhook.sh before deplying with OLM again. SKIP_CERT ?=false .PHONY: run-with-webhook run-with-webhook: export METRICS_PORT?=8080 diff --git a/hack/configure_local_webhook.sh b/hack/configure_local_webhook.sh index 984052b..2b63279 100755 --- a/hack/configure_local_webhook.sh +++ b/hack/configure_local_webhook.sh @@ -88,4 +88,10 @@ EOF_CAT oc apply -n openstack -f ${TMPDIR}/patch_webhook_configurations.yaml -oc patch "$(oc get csv -n openstack-operators -l operators.coreos.com/horizon-operator.openstack-operators -o name)" -n openstack-operators --type=json -p="[{'op': 'remove', 'path': '/spec/webhookdefinitions'}]" || true +# Scale-down operator deployment replicas to zero and remove OLM webhooks +CSV_NAME="$(oc get csv -n openstack-operators -l operators.coreos.com/horizon-operator.openstack-operators -o name)" + +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': []}]" +fi