Skip to content

Commit dffba43

Browse files
committed
Automate OLM cleanup for running local operator w/ webhooks
1 parent abf7fb9 commit dffba43

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,11 @@ golangci-lint:
396396
$(LOCALBIN)/golangci-lint run --fix --timeout $(GOLINT_TIMEOUT)
397397

398398
# Used for webhook testing
399-
# Please ensure the manila-controller-manager deployment and
400-
# webhook definitions are removed from the csv before running
401-
# this. Also, cleanup the webhook configuration for local testing
402-
# before deplying with olm again.
403-
# $oc delete -n openstack validatingwebhookconfiguration/vmanila.kb.io
404-
# $oc delete -n openstack mutatingwebhookconfiguration/mmanila.kb.io
399+
# The configure_local_webhooks.sh script below will remove any OLM webhooks
400+
# for the operator and also scale its deployment replicas down to 0 so that
401+
# the operator can run locally.
402+
# Make sure to cleanup the webhook configuration for local testing by running
403+
# ./hack/clean_local_webhook.sh before deplying with OLM again.
405404
SKIP_CERT ?=false
406405
.PHONY: run-with-webhook
407406
run-with-webhook: export METRICS_PORT?=8080

hack/configure_local_webhook.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,11 @@ webhooks:
8787
EOF_CAT
8888

8989
oc apply -n openstack -f ${TMPDIR}/patch_webhook_configurations.yaml
90+
91+
# Scale-down operator deployment replicas to zero and remove OLM webhooks
92+
CSV_NAME="$(oc get csv -n openstack-operators -l operators.coreos.com/manila-operator.openstack-operators -o name)"
93+
94+
if [ -n "${CSV_NAME}" ]; then
95+
oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/install/spec/deployments/0/spec/replicas', 'value': 0}]"
96+
oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/webhookdefinitions', 'value': []}]"
97+
fi

0 commit comments

Comments
 (0)