-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Do not GC exited containers in running pods #53167
Do not GC exited containers in running pods #53167
Conversation
/release-note |
/test pull-kubernetes-unit |
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.
Looks good with minor nits.
@@ -820,6 +820,15 @@ func (kl *Kubelet) podIsTerminated(pod *v1.Pod) bool { | |||
return status.Phase == v1.PodFailed || status.Phase == v1.PodSucceeded || (pod.DeletionTimestamp != nil && notRunning(status.ContainerStatuses)) | |||
} | |||
|
|||
// IsPodTerminated returns trus if the pod with the provided UID is in a terminated state ("Failed" or "Succeeded") |
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.
nit: add or if the pod has been deleted.
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
@@ -65,9 +65,10 @@ var ( | |||
ErrVersionNotSupported = errors.New("Runtime api version is not supported") | |||
) | |||
|
|||
// podDeletionProvider can determine if a pod is deleted | |||
type podDeletionProvider interface { | |||
// podStateProvider can determine if a pod is deleted |
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.
s/is deleted/is deleted or terminated
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
We should cherry-pick this to 1.8 and 1.7. |
0571f1a
to
4300c75
Compare
/test pull-kubernetes-e2e-gce-bazel |
/lgtm |
Let's wait for 1.8.1. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dashpole, yujuhong Associated issue: 45896 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test pull-kubernetes-e2e-gce-etcd3 |
/retest |
Automatic merge from submit-queue (batch tested with PRs 44596, 52708, 53163, 53167, 52692). If you want to cherry-pick this change to another branch, please follow the instructions here. |
@dashpole could you patch 1.7 as well? Thanks. |
@yujuhong can you add the cherrypick-candidate label to this? Thanks |
@dashpole, ping! |
Commit found in the "release-1.7" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked. |
Automatic merge from submit-queue (batch tested with PRs 16896, 16908, 16935, 16898, 16090). UPSTREAM: 53167: Do not GC exited containers in running pods kubernetes/kubernetes#53167 xref https://bugzilla.redhat.com/show_bug.cgi?id=1486356 I think this might fix the build issues we are having with init container status corruption Thanks to @aveshagarwal for spotting this getting picked to kube 1.7 👍 @frobware @derekwaynecarr @smarterclayton @vikaslaad
This fixes a regression introduced by #45896, and was identified by #52462.
This bug causes the kubelet to garbage collect exited containers in a running pod.
This manifests in strange and confusing state when viewing the cluster. For example, it can show running pods as having no init container (see #52462), if that container has exited and been removed.
This PR solves this problem by only removing containers and sandboxes from terminated pods.
The important line change is:
if cgc.podDeletionProvider.IsPodDeleted(podUID) || evictNonDeletedPods {
--->if cgc.podStateProvider.IsPodDeleted(podUID) || (cgc.podStateProvider.IsPodTerminated(podUID) && evictTerminatedPods) {
cc @MrHohn @yujuhong @kubernetes/sig-node-bugs