-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
Ensure EndpointSlice exist if Endpoint is found #84421
Conversation
Hi @tnqn. Thanks for your PR. I'm waiting for a kubernetes 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. |
689e236
to
c42069c
Compare
/assign @robscott |
Hey @tnqn, thanks for catching this! Looks like a good fix on first glance, will try to take a closer look at this tomorrow. |
/priority important-soon |
@robscott thanks for reviewing 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.
Hey @tnqn, this looks great, just have a suggestion on how to simplify the tests you're adding. I spun up an e2e cluster with this branch and the upgrade worked as expected simply by toggling the EndpointSlice feature flag on the apiserver manifest. Thanks for the fix!
@@ -98,6 +108,28 @@ func TestEndpointsAdapterGet(t *testing.T) { | |||
if !apiequality.Semantic.DeepEqual(endpoints, testCase.expectedEndpoints) { | |||
t.Errorf("Expected endpoints: %v, got: %v", testCase.expectedEndpoints, endpoints) | |||
} | |||
|
|||
epSliceList, err := client.DiscoveryV1alpha1().EndpointSlices(testCase.namespaceParam).List(metav1.ListOptions{}) |
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.
All of this test logic can actually be simplified because the EndpointSlice created here will always have a consistent name (nameParam here, but generally just kubernetes
). I think it would make sense to test based on the existence of that EndpointSlice specifically with a Get
call instead of a List
.
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.
Makes sense. I have updated, PTAL.
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.
Hey @tnqn, this looks great, I think it could be simplified one more step to just use the deepEqual whether or not the expected value was nil. Something like what's done above for Endpoints: https://github.com/kubernetes/kubernetes/blob/master/pkg/master/reconcilers/endpointsadapter_test.go#L262-L264
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.
Sure, done.
c42069c
to
8fe9681
Compare
@robscott thanks for the suggestion! |
8fe9681
to
1610e78
Compare
Thanks for catching this @tnqn! This fix works well for me. /lgtm |
Can you clarify this point? Does the endpoints controller not reconcile the |
1610e78
to
264a333
Compare
The endpoints controller is not in charge of the kubernetes/pkg/controller/endpointslice/endpointslice_controller.go Lines 260 to 264 in 8d8a068
It's the EndpointReconciler (leaseEndpointReconciler by default) in masters reconciling its Endpoints and EndpointSlice: kubernetes/pkg/master/reconcilers/lease.go Line 162 in 8d8a068
I think it's the same issue you mentioned that EndpointSlices for masters must be created by themselves to make kube-controller-manager reach them. |
/retest |
264a333
to
7294b31
Compare
/retest |
6933823
to
f3041fa
Compare
The EndpointSlice for masters was not created after enabling EndpointSlice feature on a pre-existing cluster. This was because the Endpoint object had been created and ReconcileEndpoints would skip creating or updating it after EndpointSlice feature is enabled. This patch ensures EndpointSlice is consistent with Endpoints after the reconciler reconciles Endpoints even if Endpoints is unchanged. It also avoids an update if the desired EndpointSlice matches the existing one.
f3041fa
to
92ceb16
Compare
/approve @robscott has final lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, tnqn 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 |
Thanks! @liggitt /retest |
Thanks for all your work on this @tnqn! /lgtm |
/retest |
What type of PR is this?
/kind bug
What this PR does / why we need it:
The EndpointSlice for masters was not created after enabling EndpointSlice feature on a pre-existing cluster. This was because the Endpoint object had been created and ReconcileEndpoints would skip creating or updating it after EndpointSlice feature is enabled.
This patch ensures EndpointSlice is consistent with Endpoints after the reconciler reconciles Endpoints even if Endpoints is unchanged. It also avoids an update if the desired EndpointSlice matches the existing one.
Which issue(s) this PR fixes:
Fixes #84419
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: