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

Delete nodes from k8s api during rolling-update #5794

Merged

Conversation

justinsb
Copy link
Member

This prevents a race where if the new node comes back with the same
name, it will still be cordoned. This seems to be more likely on GCE.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 17, 2018
Copy link
Member

@geojaz geojaz left a comment

Choose a reason for hiding this comment

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

/lgt... hrm.

Why have we waited to hit this before implementing deleteNode on the k8s side?

This code works, but it feels a bit weird to me.
I'm a little bit concerned that we don't seem to have a way to differentiate between node $A launched on Monday and node $A launched on Tuesday (whether a k8s/k8s issue or a kops issue).

It's probably not an incredibly common problem, but it doesn't seem unreasonable to imagine this could be a fairly common edge case.

Is the only time we'd conceivably have two nodes in the case of cordoning/rolling-update or run into this?

Could we just assign the node a uuid?
This may be just a kops problem and if so, that's fine with me- let's fix it here,

@@ -172,12 +175,26 @@ func (r *RollingUpdateInstanceGroup) RollingUpdate(rollingUpdateData *RollingUpd
}
}

// We unregister the node before deleting it; if the replacement comes up with the same name it would otherwise still be cordoned
// (GCE seems to recycle names more rapidly)
Copy link
Member

Choose a reason for hiding this comment

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

It often seems like GCE tries to re-use names.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

// (GCE seems to recycle names more rapidly)
if !isBastion && !rollingUpdateData.CloudOnly {
if u.Node == nil {
glog.Warningf("skipping node unregister from kubernetes; node was not set")
Copy link
Member

Choose a reason for hiding this comment

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

what do you mean by "not set"?

can you use a more descriptive/useful word or phrase here pls? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Switched to glog.Warningf("no kubernetes Node associated with %s, skipping node deletion", instanceId)

This prevents a race where if the new node comes back with the same
name, it will still be cordoned.  This seems to be more likely on GCE.
@justinsb justinsb force-pushed the delete_nodes_during_rolling_update branch from 637208e to e982087 Compare September 22, 2018 20:06
@justinsb
Copy link
Member Author

justinsb commented Sep 22, 2018

So I think it's a kube problem, but the role of kops is just to make sure that we don't have two instances with the same name. (Edit: that we don't bring up a new node with the same name as an existing Node)

It's much less likely on AWS, where we name instances after their internal IP, but it could happen if the new instance reuses the same IP.

It seems to always happen on GCE with MIGs, at least right now. Not sure whether that has always been the case.

I guess the right place to fix it is for the kubelet to know that it isn't the same node as the existing node, i.e. kubelet should check the machineid or something. But that isn't happening as far as I can tell (although I think I was testing with CoreOS, and maybe CoreOS has messed up whatever check kubelet is using).

Anyway, I think deleting the node feels like the safe thing to do - it's just a little more predictable.

@geojaz
Copy link
Member

geojaz commented Sep 22, 2018

/lgtm

Ok cool- that makes sense to me, thanks for the fix and the info!

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: geojaz, justinsb

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 merged commit 89873a2 into kubernetes:master Sep 22, 2018
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/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.

None yet

3 participants