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

separate webhooks from the api types package #672

Conversation

d-honeybadger
Copy link
Contributor

What this PR does / why we need it:

Coupling api/ type packages with webhook by implementing webhook.Validator interface is, in hindsight, a bad design since api types are frequently imported in other projects and should therefore be as minimal as possible. The issue is discussed in kubernetes-sigs/controller-runtime#2596.

B/c of that, webhook.Validator and webhook.Defaulter interfaces are deprecated from controller-runtime and removed in v0.20

Moving webhooks to a separate package allows repos that import api/v1beta1 to upgrade controller-runtime to v0.20, and also prepares capdo for controller-runtime v0.20 upgrade. CustomValidator and CustomDefaulter are the kubebuilder-recommended way of doing webhooks now.

Special notes for your reviewer:

Release note:

Move webhooks to a separate package from api types

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 23, 2025
@k8s-ci-robot
Copy link

Welcome @d-honeybadger!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-digitalocean 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-digitalocean has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link

Hi @d-honeybadger. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 23, 2025
@d-honeybadger d-honeybadger force-pushed the separate-webhooks-from-api-types branch from 5d0eca9 to a1292a7 Compare January 23, 2025 21:22
coupling api/ type packages with webhook by implementing
webhook.Validator interface is, in hindsight, a bad design since api
types are frequently imported in other projects and should therefore be
as minimal as possible. The issue is discussed in kubernetes-sigs/controller-runtime#2596.

B/c of that, webhook.Validator and webhook.Defaulter interfaces are
deprecated from controller-runtime and removed in v0.20

Moving webhooks to a separate package allows repos that import
api/v1beta1 to upgrade controller-runtime to v0.20, and also prepares
capdo for controller-runtime v0.20 upgrade

Signed-off-by: dkomsa <[email protected]>
@d-honeybadger d-honeybadger force-pushed the separate-webhooks-from-api-types branch from a1292a7 to d1d8918 Compare January 23, 2025 21:26
Copy link

@m3co-code m3co-code left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@k8s-ci-robot
Copy link

@m3co-code: changing LGTM is restricted to collaborators

In response to this:

LGTM, thanks!

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@cpanato
Copy link
Member

cpanato commented Jan 24, 2025

is this something that is happening in CAPI and the other providers as well?

@cpanato
Copy link
Member

cpanato commented Jan 24, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 24, 2025
@d-honeybadger
Copy link
Contributor Author

d-honeybadger commented Jan 24, 2025

is this something that is happening in CAPI and the other providers as well?

Ah that's a great question!
They moved the webhooks out of api/ a while ago kubernetes-sigs/cluster-api#5711, and put it all the way under internal/ packages.
So now that they bumped controller-runtime recently, there wasn't much refactoring necessary.
Checked a couple providers (gcp, aws) too: they still have their webhooks within api/ and implementing webhook.Validator interface, but they'll have to switch to webhook.CustomValidator soon with the controller-runtime 0.20 upgrade.

I didn't put the webhooks under internal/: was looking for a minimal refactor, and so moved then just one level out.
LMK if you'd rather replicate the structure of CAPI, where the webhooks are under /internal packages and they have an external package aliasing any methods that can't be internal.

@gottwald
Copy link
Contributor

gottwald commented Feb 4, 2025

/approve

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: d-honeybadger, gottwald, m3co-code

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 4, 2025
@gottwald
Copy link
Contributor

gottwald commented Feb 4, 2025

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 4, 2025
@k8s-ci-robot k8s-ci-robot merged commit 06b7296 into kubernetes-sigs:main Feb 4, 2025
6 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.1.0 milestone Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants