Skip to content

Commit 8e2ef61

Browse files
gibizeropenshift-merge-bot[bot]
authored andcommitted
Improve make run-with-webhook
Do the automatic webhook cleanup and controller scaledown. Also add SKIP_FIREWALL env variable. This aligns the target with the same target in nova-operator. Closes: #114
1 parent 42fe9e5 commit 8e2ef61

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

Makefile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,22 +316,27 @@ operator-lint: gowork ## Runs operator-lint
316316
GOBIN=$(LOCALBIN) go install github.com/gibizer/[email protected]
317317
go vet -vettool=$(LOCALBIN)/operator-lint ./... ./api/...
318318

319-
# Used for webhook testing
320-
# Please ensure the placement-controller-manager deployment and
321-
# webhook definitions are removed from the csv before running
322-
# this. Also, cleanup the webhook configuration for local testing
323-
# before deplying with olm again.
324-
# $oc delete -n openstack validatingwebhookconfiguration/vplacementapi.kb.io
325-
# $oc delete -n openstack mutatingwebhookconfiguration/mplacementapi.kb.io
326319
SKIP_CERT ?=false
327320
.PHONY: run-with-webhook
328321
run-with-webhook: export METRICS_PORT?=8080
329322
run-with-webhook: export HEALTH_PORT?=8081
330-
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
323+
run-with-webhook: manifests generate fmt vet scale-down-placement-controller-csv ## Run a controller from your host.
324+
/bin/bash hack/clean_local_webhook.sh
331325
/bin/bash hack/configure_local_webhook.sh
332326
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)"
333327

334328
.PHONY: tidy
335329
tidy: ## Run go mod tidy on every mod file in the repo
336330
go mod tidy
337331
cd ./api && go mod tidy
332+
333+
OPERATOR_NAMESPACE ?= openstack-operators
334+
335+
scale-down-placement-controller-csv:
336+
@echo "Scaling placement-controller-manager to 0 in CSV"
337+
oc patch csv -n $(OPERATOR_NAMESPACE) placement-operator.v0.0.1 --type json -p='[{"op": "replace", "path": "/spec/install/spec/deployments/0/spec/replicas", "value": 0}]'
338+
@echo "Removing olm installed webhooks from CSV"
339+
$(eval has_webhooks=$(shell oc get -o json csv placement-operator.v0.0.1 | jq ".spec.webhookdefinitions"))
340+
if [ "$(has_webhooks)" != "null" ]; then \
341+
oc patch csv -n $(OPERATOR_NAMESPACE) placement-operator.v0.0.1 --type json -p='[{"op": "remove", "path": "/spec/webhookdefinitions"}]'; \
342+
fi

hack/configure_local_webhook.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ TMPDIR=${TMPDIR:-"/tmp/k8s-webhook-server/serving-certs"}
55
SKIP_CERT=${SKIP_CERT:-false}
66
CRC_IP=${CRC_IP:-$(/sbin/ip -o -4 addr list crc | awk '{print $4}' | cut -d/ -f1)}
77
FIREWALL_ZONE=${FIREWALL_ZONE:-"libvirt"}
8+
SKIP_FIREWALL=${SKIP_FIREWALL:-false}
89

9-
#Open 9443
10-
sudo firewall-cmd --zone=${FIREWALL_ZONE} --add-port=9443/tcp
11-
sudo firewall-cmd --runtime-to-permanent
10+
if [ "$SKIP_FIREWALL" = false ] ; then
11+
#Open 9443
12+
sudo firewall-cmd --zone=${FIREWALL_ZONE} --add-port=9443/tcp
13+
sudo firewall-cmd --runtime-to-permanent
14+
fi
1215

1316
# Generate the certs and the ca bundle
1417
if [ "$SKIP_CERT" = false ] ; then

0 commit comments

Comments
 (0)