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

✨Support draining unready nodes #2165

Merged
merged 1 commit into from
Feb 5, 2020

Conversation

hypnoglow
Copy link
Contributor

What this PR does / why we need it:
Adds support for draining unready nodes.

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 #1870

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 27, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @hypnoglow. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 27, 2020
@k8s-ci-robot k8s-ci-robot requested review from justinsb and ncdc January 27, 2020 20:33
@ncdc
Copy link
Contributor

ncdc commented Jan 27, 2020

/ok-to-test

FYI @michaelgugino

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 27, 2020
@hypnoglow
Copy link
Contributor Author

@michaelgugino @ncdc Does this PR covers the issue? Is anything missing?

@hypnoglow hypnoglow force-pushed the drain-unready-nodes branch from 1dc0442 to 57813cf Compare January 29, 2020 19:13
@hypnoglow hypnoglow changed the title WIP: ✨Support draining unready nodes ✨Support draining unready nodes Jan 29, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 29, 2020
@hypnoglow
Copy link
Contributor Author

/retest

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jan 29, 2020

@hypnoglow: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-cluster-api-e2e 1dc0442 link /test pull-cluster-api-e2e

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@@ -348,6 +349,12 @@ func (r *MachineReconciler) drainNode(cluster *clusterv1.Cluster, nodeName strin
DryRun: false,
}

if !noderefutil.IsNodeReady(node) {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be checking the node is unreachable instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you please elaborate? The issue stated about "unready" node. How do we want to check if the node is unreachable?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe there is any way for Cluster API to evaluate a node's reachability other than by looking at the conditions of the node in the workload cluster. Or am I missing something?

@michaelgugino @vincepri would we want to always set drainer.SkipWaitForDeleteTimeoutSeconds, or only if certain node conditions are set?

Copy link
Member

@enxebre enxebre Jan 31, 2020

Choose a reason for hiding this comment

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

This feature comes in handy when the node is unreachable, see https://kubernetes.io/docs/concepts/architecture/nodes/.
In some cases when the node is unreachable, the apiserver is unable to communicate with the kubelet on the node. The decision to delete the pods cannot be communicated to the kubelet until communication with the apiserver is re-established. In the meantime, the pods that are scheduled for deletion may continue to run on the partitioned node.
#1870 (comment)

I believe we can assume this when the nodeReady status [1] is unknown [2].

[1] https://github.com/kubernetes-sigs/cluster-api/blob/master/controllers/noderefutil/util.go#L62-L67
[2] https://github.com/kubernetes/api/blob/master/core/v1/types.go#L2318

Copy link
Contributor

Choose a reason for hiding this comment

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

100% agree with what you wrote, but I'm not clear if this is something we should always set, or only when the ready status is unknown?

Copy link
Contributor

Choose a reason for hiding this comment

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

@enxebre did you see my last question?

Copy link
Member

Choose a reason for hiding this comment

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

I think I'd be in favour of setting the flag only when the kubelet status is unknown as we deliberately want to let draining move forward in such scenario. It seems safe to let any other unknown scenario where this might happen be visible by blocking draining for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the PR to check if node ready status is "Unknown" instead of "not True". Please check if this matches what we have discussed.

@chuckha
Copy link
Contributor

chuckha commented Jan 30, 2020

/test pull-cluster-api-capd-e2e

@hypnoglow hypnoglow force-pushed the drain-unready-nodes branch from 57813cf to ec648ec Compare February 4, 2020 20:53
// IsNodeUnreachable returns true if a node is unreachable.
// Node is considered unreachable when its ready status is "Unknown".
func IsNodeUnreachable(node *corev1.Node) bool {
if node == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we need this check. It should only ever be called with a valid node.

@ncdc
Copy link
Contributor

ncdc commented Feb 4, 2020

/assign @enxebre @michaelgugino

@k8s-ci-robot
Copy link
Contributor

@ncdc: GitHub didn't allow me to assign the following users: enxebre.

Note that only kubernetes-sigs members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @enxebre @michaelgugino

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.

@ncdc ncdc added this to the v0.3.0 milestone Feb 5, 2020
@ncdc
Copy link
Contributor

ncdc commented Feb 5, 2020

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hypnoglow, ncdc

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 Feb 5, 2020
@k8s-ci-robot k8s-ci-robot merged commit 82a7ac0 into kubernetes-sigs:master Feb 5, 2020
@@ -348,6 +349,11 @@ func (r *MachineReconciler) drainNode(cluster *clusterv1.Cluster, nodeName strin
DryRun: false,
}

if noderefutil.IsNodeUnreachable(node) {
// When the node is unreachable and some pods are not evicted for as long as this timeout, we ignore them.
Copy link
Member

Choose a reason for hiding this comment

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

We should probably include a logging message here e.g "This node is unreachable, draining will wait for pod deletion during skipWaitForDeleteTimeoutSeconds after the request and will skip otherwise." cc @ncdc @alexander-demichev @hypnoglow

Copy link
Contributor

Choose a reason for hiding this comment

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

I can open a PR if everyone is ok with the change.

Copy link
Member

Choose a reason for hiding this comment

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

Do we want this to be something end users are aware of? If so, I would suggest an Event in addition to the log message.

@riking
Copy link

riking commented Feb 15, 2020

The shouldSkipPod function doesn't seem like it takes into account nodes that come back or become unhealthy during the drain. Additionally, I'm pretty sure that kubelet updates the DeletionTimestamp multiple times while evicting a pod.

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update drain lib to support unreachable nodes
9 participants