mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +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.
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user