kubectl: fix infinite drain retry for pods migrated to other nodes#138237
kubectl: fix infinite drain retry for pods migrated to other nodes#138237sakshar2303 wants to merge 1 commit intokubernetes:masterfrom
Conversation
Signed-off-by: Sakshar Dhawan <sakshardhawanfzk@gmail.com>
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions 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-sigs/prow repository. |
|
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The DetailsInstructions 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-sigs/prow repository. |
|
Hi @sakshar2303. 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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sakshar2303 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Description
This PR fixes a bug in
kubectl drainwhere the eviction process could enter an infinite retry loop for pods that have already migrated to a different node.The Issue
Currently, when the Eviction API returns a
429 Too Many Requestserror (often due to a PodDisruptionBudget),kubectlretries the eviction every 5 seconds. However, it does not re-verify the pod's state during these retries. In scenarios involving StatefulSets or rapid rescheduling, a pod might be deleted and recreated on a different node whilekubectlis still retrying the old eviction. This causeskubectlto attempt evicting a pod that is no longer on the target node, potentially blocking the drain operation indefinitely.Changes
staging/src/k8s.io/kubectl/pkg/drain/evict.go.pod.Spec.NodeNameno longer matches the node being drained, the pod is considered "successfully moved" and the drain proceeds to the next pod.Validation
NodeNamechanges during the retry window.staging/src/k8s.io/kubectl/pkg/drain/drain_test.go.Fixes # (Link the issue here once you've created it, or mention it's a found bug)
/sig cli
/area kubectl
/kind bug