Skip to content

Commit f3611e3

Browse files
Merge pull request #485 from abays/olm_webhook_cleanup
Automate OLM cleanup for running local operator w/ webhooks
2 parents e3c5ebb + 285b55f commit f3611e3

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
@@ -358,12 +358,11 @@ operator-lint: gowork ## Runs operator-lint
358358
go vet -vettool=$(LOCALBIN)/operator-lint ./... ./api/...
359359

360360
# Used for webhook testing
361-
# Please ensure the keystone-controller-manager deployment and
362-
# webhook definitions are removed from the csv before running
363-
# this. Also, cleanup the webhook configuration for local testing
364-
# before deplying with olm again.
365-
# $oc delete -n openstack validatingwebhookconfiguration/vkeystoneapi.kb.io
366-
# $oc delete -n openstack mutatingwebhookconfiguration/mkeystoneapi.kb.io
361+
# The configure_local_webhooks.sh script below will remove any OLM webhooks
362+
# for the operator and also scale its deployment replicas down to 0 so that
363+
# the operator can run locally.
364+
# Make sure to cleanup the webhook configuration for local testing by running
365+
# ./hack/clean_local_webhook.sh before deplying with OLM again.
367366
SKIP_CERT ?=false
368367
.PHONY: run-with-webhook
369368
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/keystone-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)