From 5ce298c9aaa93708cd46df40ba20a080cc1a8b18 Mon Sep 17 00:00:00 2001 From: Derek Carr Date: Mon, 6 Mar 2017 13:21:33 -0500 Subject: [PATCH] provide active pods to cgroup cleanup --- pkg/kubelet/kubelet_pods.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pkg/kubelet/kubelet_pods.go b/pkg/kubelet/kubelet_pods.go index 659e7ff8196..f408717c3c4 100644 --- a/pkg/kubelet/kubelet_pods.go +++ b/pkg/kubelet/kubelet_pods.go @@ -687,11 +687,7 @@ func (kl *Kubelet) podIsTerminated(pod *v1.Pod) bool { // restarted. status = pod.Status } - if status.Phase == v1.PodFailed || status.Phase == v1.PodSucceeded { - return true - } - - return false + return status.Phase == v1.PodFailed || status.Phase == v1.PodSucceeded || (pod.DeletionTimestamp != nil && notRunning(status.ContainerStatuses)) } // OkToDeletePod returns true if all required node-level resources that a pod was consuming have @@ -848,7 +844,7 @@ func (kl *Kubelet) HandlePodCleanups() error { // Remove any cgroups in the hierarchy for pods that are no longer running. if kl.cgroupsPerQOS { - kl.cleanupOrphanedPodCgroups(cgroupPods, runningPods) + kl.cleanupOrphanedPodCgroups(cgroupPods, activePods) } kl.backOff.GC() @@ -1511,13 +1507,12 @@ func (kl *Kubelet) GetPortForward(podName, podNamespace string, podUID types.UID // cleanupOrphanedPodCgroups removes cgroups that should no longer exist. // it reconciles the cached state of cgroupPods with the specified list of runningPods -func (kl *Kubelet) cleanupOrphanedPodCgroups(cgroupPods map[types.UID]cm.CgroupName, runningPods []*kubecontainer.Pod) { +func (kl *Kubelet) cleanupOrphanedPodCgroups(cgroupPods map[types.UID]cm.CgroupName, activePods []*v1.Pod) { // Add all running pods to the set that we want to preserve podSet := sets.NewString() - for _, pod := range runningPods { - podSet.Insert(string(pod.ID)) + for _, pod := range activePods { + podSet.Insert(string(pod.UID)) } - pcm := kl.containerManager.NewPodContainerManager() // Iterate over all the found pods to verify if they should be running