mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
provide active pods to cgroup cleanup
This commit is contained in:
parent
0fad9ce5e2
commit
5ce298c9aa
@ -687,11 +687,7 @@ func (kl *Kubelet) podIsTerminated(pod *v1.Pod) bool {
|
|||||||
// restarted.
|
// restarted.
|
||||||
status = pod.Status
|
status = pod.Status
|
||||||
}
|
}
|
||||||
if status.Phase == v1.PodFailed || status.Phase == v1.PodSucceeded {
|
return status.Phase == v1.PodFailed || status.Phase == v1.PodSucceeded || (pod.DeletionTimestamp != nil && notRunning(status.ContainerStatuses))
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OkToDeletePod returns true if all required node-level resources that a pod was consuming have
|
// 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.
|
// Remove any cgroups in the hierarchy for pods that are no longer running.
|
||||||
if kl.cgroupsPerQOS {
|
if kl.cgroupsPerQOS {
|
||||||
kl.cleanupOrphanedPodCgroups(cgroupPods, runningPods)
|
kl.cleanupOrphanedPodCgroups(cgroupPods, activePods)
|
||||||
}
|
}
|
||||||
|
|
||||||
kl.backOff.GC()
|
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.
|
// cleanupOrphanedPodCgroups removes cgroups that should no longer exist.
|
||||||
// it reconciles the cached state of cgroupPods with the specified list of runningPods
|
// 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
|
// Add all running pods to the set that we want to preserve
|
||||||
podSet := sets.NewString()
|
podSet := sets.NewString()
|
||||||
for _, pod := range runningPods {
|
for _, pod := range activePods {
|
||||||
podSet.Insert(string(pod.ID))
|
podSet.Insert(string(pod.UID))
|
||||||
}
|
}
|
||||||
|
|
||||||
pcm := kl.containerManager.NewPodContainerManager()
|
pcm := kl.containerManager.NewPodContainerManager()
|
||||||
|
|
||||||
// Iterate over all the found pods to verify if they should be running
|
// Iterate over all the found pods to verify if they should be running
|
||||||
|
Loading…
Reference in New Issue
Block a user