-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
kubectl: Allow 'drain --force' to remove orphaned pods #41864
kubectl: Allow 'drain --force' to remove orphaned pods #41864
Conversation
pkg/kubectl/cmd/drain.go
Outdated
@@ -308,7 +308,10 @@ func (o *DrainOptions) unreplicatedFilter(pod api.Pod) (bool, *warning, *fatal) | |||
} | |||
|
|||
sr, err := o.getPodCreator(pod) | |||
if err != nil { | |||
removeOrphandedPod := apierrors.IsNotFound(err) && o.Force |
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.
removeOrphanedPod
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.
just nesting the condition might be easier to follow
if err != nil {
// if we're forcing, remove orphaned pods with a warning
if apierrors.IsNotFound(err) && o.Force {
return true, &warning{err.Error()}, nil
}
return false, nil, &fatal{err.Error()}
}
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.
Done.
does any of the help need updating? |
ae1bdae
to
46271e5
Compare
@liggitt Help has been updated. |
pkg/kubectl/cmd/drain.go
Outdated
@@ -151,7 +151,8 @@ var ( | |||
DaemonSet controller, which ignores unschedulable markings. If there are any | |||
pods that are neither mirror pods nor managed by ReplicationController, | |||
ReplicaSet, DaemonSet, StatefulSet or Job, then drain will not delete any pods unless you | |||
use --force. | |||
use --force. --force will also allow deletion to proceed if the managing resource of one | |||
or more pods is missing. |
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.
indent
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.
Done. Tabs, yuck.
nit on help indent, LGTM |
46271e5
to
92d739b
Compare
i updated text w/ a release-note, @deads2k can we get an review please? |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED The following people have approved this PR: deads2k, marun Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
@derekwaynecarr How to merge post-approval? |
wait in the long, long queue. if the submit queue has a green check mark, you're in the line. |
Automatic merge from submit-queue (batch tested with PRs 41857, 41864, 40522, 41835, 41991) |
If the managing resource of a given pod (e.g. DaemonSet/ReplicaSet/etc) is deleted (effectively orphaning the pod), and
kubectl drain --force
is invoked on the node hosting the pod, the command would fail with an error indicating that the managing resource was not found. This PR reduces the error to a warning if--force
is specified, allowing nodes with orphaned pods to be drained.Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1424678
cc: @derekwaynecarr