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

🌱 Add a check to the Cluster webhook to ensure ClusterClass exists #5585

Conversation

killianmuldoon
Copy link
Contributor

Signed-off-by: killianmuldoon [email protected]

This change adds an additional check to the Cluster Webhook to ensure that a ClusterClass referenced by a cluster exists. If the ClusterClass does not exist the Cluster creation or update is rejected.

This check introduces an expected ordering in the creation and update of the ClusterClass and Cluster objects, and it adds a client to the webhook that is used to fetch the referenced ClusterClass from the API server on Cluster creation and update.

Related to #5537

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 4, 2021
webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster_test.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
@killianmuldoon killianmuldoon force-pushed the webhook/add-clusterclass-check branch from 6b6a1b6 to 8f35a42 Compare November 5, 2021 16:53
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 5, 2021
@killianmuldoon
Copy link
Contributor Author

This is now rebased on top of #5596 and shouldn't be merged before that PR. The most recent commit adds the clusterClassExists checks inline with the other validation checks.

Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

I'll re-review once the other PR is merged

controllers/topology/cluster_controller_test.go Outdated Show resolved Hide resolved
webhooks/cluster.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 8, 2021
@killianmuldoon killianmuldoon force-pushed the webhook/add-clusterclass-check branch from 8f35a42 to e3e343d Compare November 8, 2021 17:58
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 8, 2021
@killianmuldoon killianmuldoon force-pushed the webhook/add-clusterclass-check branch from e3e343d to 9c2b283 Compare November 8, 2021 18:06
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

last round of nits from my side

webhooks/cluster.go Outdated Show resolved Hide resolved
webhooks/cluster_test.go Outdated Show resolved Hide resolved
webhooks/cluster_test.go Outdated Show resolved Hide resolved
@killianmuldoon killianmuldoon force-pushed the webhook/add-clusterclass-check branch from 9c2b283 to 1e0d06a Compare November 9, 2021 10:06
@killianmuldoon killianmuldoon force-pushed the webhook/add-clusterclass-check branch from 1e0d06a to ac8bed0 Compare November 9, 2021 10:13
@sbueringer
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 9, 2021
@fabriziopandini
Copy link
Member

/approve
/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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 Nov 9, 2021
@k8s-ci-robot k8s-ci-robot merged commit 6f28707 into kubernetes-sigs:main Nov 9, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.1 milestone Nov 9, 2021
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. 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.

6 participants