Skip to content

Commit

Permalink
Automate OLM cleanup for running local operator w/ webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
abays authored and gibizer committed Nov 21, 2024
1 parent 1d933fc commit a892a7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,11 @@ gowork: ## Generate go.work file
go work sync

# Used for webhook testing
# Please ensure the mariadb-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/vmariadb.kb.io
# $oc delete -n openstack mutatingwebhookconfiguration/mmariadb.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
Expand Down
8 changes: 8 additions & 0 deletions hack/configure_local_webhook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,11 @@ webhooks:
EOF_CAT

oc apply -n openstack -f ${TMPDIR}/patch_webhook_configurations.yaml

# Scale-down operator deployment replicas to zero and remove OLM webhooks
CSV_NAME="$(oc get csv -n openstack-operators -l operators.coreos.com/mariadb-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

0 comments on commit a892a7e

Please sign in to comment.