-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🌱 Added C-R validating webhook for KCP scale subresource #5697
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
🌱 Added C-R validating webhook for KCP scale subresource #5697
Conversation
Hi @dharmjit. 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 Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
/ok-to-test @dharmjit Can you please rebase on top of main to get rid of the merge conflict? (otherwise the tests won't run) |
946920e
to
f9325fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thx! A bunch of nits, but nothing major :)
// +kubebuilder:webhook:verbs=create;update,path=/validate-scale-controlplane-cluster-x-k8s-io-v1beta1-kubeadmcontrolplane,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=controlplane.cluster.x-k8s.io,resources=kubeadmcontrolplanes/scale,versions=v1beta1,name=validation-scale.kubeadmcontrolplane.controlplane.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 | ||
|
||
// KCPScaleValidator validates KCP for replicas. | ||
type KCPScaleValidator struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the name, maybe we should call it just KCPScale
or KubeadmControlPlane
(let's wait for other opinions before potentially changing it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not KubeadmControlPlane
as it's distinctly the scale subresource, and it's very much an admission webhook, so it's more or less fine, however maybe ScaleValidator
to avoid philosophically stuttering..
// KCPScaleValidator implements admission.DecoderInjector. | ||
// A decoder will be automatically injected. | ||
|
||
// InjectDecoder injects the decoder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// KCPScaleValidator implements admission.DecoderInjector. | |
// A decoder will be automatically injected. | |
// InjectDecoder injects the decoder. | |
// InjectDecoder injects the decoder. | |
// KCPScaleValidator implements admission.DecoderInjector. | |
// A decoder will be automatically injected. |
Regrading back porting: Let's discuss that later, usually it's just triggering the cherry pick bot (but we have to decide to which branches we want to backport) Regarding testing: I would suggest a table test ~ like it's done here:
But you have to additionally:
fakeScheme = runtime.NewScheme()
_ = kcpv1.AddToScheme(scheme) |
0d14b00
to
51a49b9
Compare
@sbueringer @randomvariable, PTAL, I had fixed the review comments and also added the test for the webhook. |
51a49b9
to
38347d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx!!
One last nit from my side, otherwise lgtm.
Feel free to resolve the resolved conversations.
38347d8
to
28138de
Compare
/lgtm /assign @randomvariable |
mgr.GetWebhookServer().Register("/validate-scale-controlplane-cluster-x-k8s-io-v1beta1-kubeadmcontrolplane", &webhook.Admission{ | ||
Handler: &kcpwebhooks.ScaleValidator{ | ||
Client: mgr.GetClient(), | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbueringer Sidenote, the Scale subresource should probably have top-level support in Controller Runtime
|
||
if !externalEtcd { | ||
if scale.Spec.Replicas%2 == 0 { | ||
return admission.Denied("replicas cannot be an even number when using managed etcd") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return admission.Denied("replicas cannot be an even number when using managed etcd") | |
return admission.Denied("replicas cannot be an even number when etcd is stacked") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this message is the same in the regular webhook, if yes, let's update both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the message at both places.
@dharmjit Looks good, can you please squash the commits? |
Signed-off-by: Dharmjit Singh <sdharmjit@vmware.com>
c9b23d9
to
035e915
Compare
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri 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 |
Signed-off-by: Dharmjit Singh sdharmjit@vmware.com
What this PR does / why we need it:
This PR introduces a
Controller-Runtime
validating webhook forkubeadmControlPlane
scale subresource.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #5466