-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Preserve loadBalancerClass on Service updates #3641
Preserve loadBalancerClass on Service updates #3641
Conversation
Welcome @diversario! |
Hi @diversario. 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. |
When Service object is updated, ensure that load balancer class is preserved. Co-authored-by: Jack Andersen <[email protected]>
df5666e
to
a1f49f9
Compare
// if yes, then leave it be because someone wanted it that way, let the user deal with the error | ||
if newSvc.Spec.LoadBalancerClass == nil || *newSvc.Spec.LoadBalancerClass == "" { | ||
newSvc.Spec.LoadBalancerClass = oldSvc.Spec.LoadBalancerClass | ||
|
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 was just thinking some corner cases - would this change cause some issue when this field in the newSvc is intended to be nil or ""?
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.
Since this handler is for updates to an existing service only, there's a couple of reasons the field would be missing/empty:
- User is updating the service object via
patch
, submitting only modified fields. In this case, tacking the LBC field onto the update is a noop, and there's no change in behavior. - User is updating the service object via
put
(this is thekubectl replace
) and omits the field. The normal response would be an error, as the field is immutable.
With this handler, the error does not occur as we putting the field back. This is a change in behavior.
Whether this change is unexpected - I think it is not, because presumably user has enabled the webhook, is aware of the webhook effects, and expects LB Services in their cluster to be managed by AWS LBC. So this change, then, just prevents the user from running into an error (and this is the entire reason behind this PR because our deployment tooling - Helm - runs into this very error).
Importantly, because the handler inspects the existing Service, it will only touch service that are known to be managed by AWS LBC, and not something else.
/ok-to-test |
@diversario, thanks for the contribution. I'm good with the changes, can you please add the manual tests you've done in the PR descriptions? |
/lgtm |
Updated description. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: diversario, oliviassss 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 |
Issue
#3617
Description
See the linked issue for the observed problem.
This PR enables service mutator to run on updates to service objects (the
UPDATE
operation needs to be added to the webhook configuration for this to work).Update mutator will only act on service objects that have
spec.loadBalancerClass
set to a non-empty value. When this is true, the incoming (updated) Service object will be updated to have the samespec.loadBalancerClass
as the existing Service object.Considering that
spec.loadBalancerClass
, once set, cannot be unset or modified, this change prevents unexpected validation errors in cases ofUPDATE
operation with Service object that omits thespec.loadBalancerClass
field. This is the case forhelm rollback --force
, described in the linked issue, as well as forkubectl replace
command.Documentation may need to be updated depending on the outcome of aws/eks-charts#1063 - that PR changes some chart values that are being referenced in the docs.
Testing
This change was tested using the helm chart built from #3653.
For testing, I had MWC with no UPDATE operation first (as it is currently configured), then I enabled it in the chart.
Tested by creating a Service via
kubectl apply
, updating it viakubectl apply
, and then replacing it viakubectl replace
.kubectl replace
previously would fail with validation error due to attempt to modify spec.loadBalancerClass. No longer fails.I submitted Service manifests with and without the
spec.loadBalancerClass
field.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Checklist
README.md
, or thedocs
directory)BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯