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

Allow nodeName updates when endPoint is updated. #68575

Merged
merged 1 commit into from
Sep 25, 2018

Conversation

prameshj
Copy link
Contributor

@prameshj prameshj commented Sep 12, 2018

This change removes a validation check that disallows nodeName change in a service endpoint update.
One scenario where nodeName can change for the same ip address is if the endpoints are in hostNetwork mode and nodes are being added/deleted.
With the current validation check, if endpoints controller misses a pod delete event, future endpoint updates will never succeed. This will result in stale
endpoints for the service.

What this PR does / why we need it:

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 #66720
Special notes for your reviewer:

Release note:

Allows changing nodeName in endpoint update.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 12, 2018
@k8s-ci-robot k8s-ci-robot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 12, 2018
@bowei
Copy link
Member

bowei commented Sep 12, 2018

testing?

@bowei
Copy link
Member

bowei commented Sep 12, 2018

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 12, 2018
@bowei
Copy link
Member

bowei commented Sep 12, 2018

this needs a release note

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 12, 2018
@prameshj
Copy link
Contributor Author

Verified via kubectl that nodeNames can now be changed for endpoints. Without my change, I see the error:
'Endpoints "test" is invalid: [subsets[0].addresses[1].nodeName: Forbidden: Cannot change NodeName for ...'

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Sep 12, 2018
@bowei
Copy link
Member

bowei commented Sep 12, 2018

/assign @freehan

@bowei
Copy link
Member

bowei commented Sep 12, 2018

/assign @thockin for approval

@freehan freehan added the kind/bug Categorizes issue or PR as related to a bug. label Sep 12, 2018
@k8s-ci-robot k8s-ci-robot removed the needs-kind Indicates a PR lacks a `kind/foo` label and requires one. label Sep 12, 2018
@@ -12968,8 +12968,8 @@ func TestEndpointAddressNodeNameUpdateRestrictions(t *testing.T) {
// Check that NodeName cannot be changed during update (if already set)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/cannot/can

@@ -12965,11 +12965,11 @@ func newNodeNameEndpoint(nodeName string) *core.Endpoints {
func TestEndpointAddressNodeNameUpdateRestrictions(t *testing.T) {
oldEndpoint := newNodeNameEndpoint("kubernetes-node-setup-by-backend")
updatedEndpoint := newNodeNameEndpoint("kubernetes-changed-nodename")
// Check that NodeName cannot be changed during update (if already set)
// Check that NodeName can be changed during update
Copy link
Contributor

Choose a reason for hiding this comment

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

add a comment:
This is to accommodate the case where node IP changed or pod CIDR changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit:add the comment

@@ -5134,19 +5134,6 @@ func buildEndpointAddressNodeNameMap(subsets []core.EndpointSubset) map[string]s
return ipToNodeName
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can also get rid of the helper function that constructs ipToNode.

@k8s-ci-robot k8s-ci-robot removed the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 14, 2018
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 14, 2018
One scenario where nodeName can change for the same ip address is if
the endpoints are in hostNetwork mode and nodes are being added/deleted.
With the current validation check, if endpoints controller misses a pod
delete event, future endpoint updates will never succeed.

removed unused helper functions
@prameshj
Copy link
Contributor Author

/retest

@freehan
Copy link
Contributor

freehan commented Sep 17, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 17, 2018
@freehan
Copy link
Contributor

freehan commented Sep 17, 2018

/assign @thockin for approval

@k8s-ci-robot
Copy link
Contributor

@freehan: GitHub didn't allow me to assign the following users: for, approval.

Note that only kubernetes members and repo collaborators can be assigned.
For more information please see the contributor guide

In response to this:

/assign @thockin for approval

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.

@thockin
Copy link
Member

thockin commented Sep 17, 2018

So, to trigger this bug you have to have an pod on node X with IP A, node X goes away, node Y comes up. Controller manager misses the old pod going away. Pod gets rescheduled onto Y and gets address A again?

That seems pretty niche - am I getting it right?

@prameshj
Copy link
Contributor Author

That is one case. You can also trigger it with service endpoints in hostNetwork mode and nodes going up and down - autoscaling or other reasons. If there are a lot of these changes, endpoints controller can miss the endpoint deletion events.

@freehan
Copy link
Contributor

freehan commented Sep 17, 2018

This bug triggers more often with preempt-able VMs + pods with host network.

@thockin
Copy link
Member

thockin commented Sep 17, 2018

Missing events is a MAJOR bug. If we can demonstrate that, we should really REALLY fix that.

That said, I am going to OK this. I think it was pedantic, and should be OK.

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: freehan, prameshj, thockin

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 Sep 17, 2018
@k8s-ci-robot k8s-ci-robot merged commit f289353 into kubernetes:master Sep 25, 2018
k8s-ci-robot added a commit that referenced this pull request Oct 3, 2018
…75-upstream-release-1.12

Automated cherry pick of #68575: Allow nodeName updates when endPoint is updated.
@ottoyiu
Copy link

ottoyiu commented Oct 5, 2018

Confirmed to be hitting this by having scale down events (removal of nodes) in v1.10.5. Thanks for the fix!

@lfundaro
Copy link

Thanks for the fix ! I think this also solves the issue referenced here #69668 . I am not able to confirm as we use kubernetes through GCP and they have not yet released v1.12.1 but looks like the same problem.

@liggitt
Copy link
Member

liggitt commented Nov 30, 2018

Any reason not to pick this to 1.10 and 1.11 as well?

@liggitt
Copy link
Member

liggitt commented Nov 30, 2018

Missing events is a MAJOR bug. If we can demonstrate that, we should really REALLY fix that.

Not reacting to individual events is possible, and I don't think it's a bug. The validation prior to this PR depended on the endpoints controller first deleting the IP+old-node from the endpoints object, then separately adding the IP+new-node. That's an edge-triggered behavior, and we want to be level-triggered, so that the following works:

  1. endpoints controller computes endpoints for service foo to be {pod:a, node:a, ip: 1.2.3.4}
  2. endpoints controller goes down (or drops watch)
  3. pod a is deleted, node a is deleted, node b is created, pod b is created with IP 1.2.3.4
  4. endpoints controller comes up (or relists)
  5. endpoints controller computes endpoints for service foo to be {pod:b, node:b, ip: 1.2.3.4} and tries to do a single update that changes the node name associated with IP 1.2.3.4

To accomodate that, loosening the validation to allow a change is correct.

@liggitt
Copy link
Member

liggitt commented Nov 30, 2018

opened picks to 1.10 and 1.11

k8s-ci-robot added a commit that referenced this pull request Dec 3, 2018
…5-upstream-release-1.11

Automated cherry pick of #68575: Allow nodeName updates when endPoint is updated.
k8s-ci-robot added a commit that referenced this pull request Dec 10, 2018
…5-upstream-release-1.10

Automated cherry pick of #68575: Allow nodeName updates when endPoint is updated.
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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

controller manager fails to update endpoints of host network services when nodeName has changed
8 participants