Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove OLM webhooks when running 'make run-with-webhook' #372

Merged

Conversation

abays
Copy link
Contributor

@abays abays commented Oct 11, 2024

When using make run-with-webhook, local versions of the operator and its webhooks are added to the cluster. If the operator was previously installed via OLM, then there might be lingering webhooks from that installation. We've previously been assuming that the user would manually remove them, but we should just get rid of them ourselves since those OLM webhooks need to be deleted anyhow for the local webhooks to function unimpeded.

@openshift-ci openshift-ci bot requested review from dprince and viroel October 11, 2024 12:13
Copy link
Contributor

openshift-ci bot commented Oct 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abays

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@abays abays requested review from stuggi and rabi and removed request for viroel October 11, 2024 12:13
@@ -87,3 +87,5 @@ webhooks:
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We document to remove webhooks along with the controller-manager in other operators though, rather than patching the csv in this script. Maybe we make it consistent across operators.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. That was my thinking: replicate the pattern in all operators. But first I wanted to get your feedback on this initial form. Thanks for the review!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rabi What would you think about adding another oc patch to configure-local-webhooks.sh to scale-down the CSV's deployment replicas to zero and then changing the comments here [1] to just mention the cleanup (since we will automatically be handling the scale-down and removal of OLM webhooks)? i.e. something like:

# 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 
# before deplying with OLM again, i.e.
# $oc delete -n openstack validatingwebhookconfiguration/vhorizon.kb.io
# $oc delete -n openstack mutatingwebhookconfiguration/mhorizon.kb.io

[1]

horizon-operator/Makefile

Lines 356 to 361 in 506b284

# 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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sounds good, if we're automating it, we should do that as well. For local webhook cleanup there is a script already and we can just mention that. https://github.com/openstack-k8s-operators/horizon-operator/blob/main/hack/clean_local_webhook.sh

Copy link

@rabi rabi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Oct 14, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 506b284 into openstack-k8s-operators:main Oct 14, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants