Moving deletion behavior from the NC into PodGC

This should be a NOP because we're just moving functionality
around and thanks to #35476, the podGC controller should always
run anyway.
This commit is contained in:
Anirudh
2016-10-25 11:18:58 -07:00
parent b47d862aea
commit 05365d7cb2
3 changed files with 28 additions and 14 deletions

View File

@@ -125,6 +125,7 @@ func (gcc *PodGCController) gc() {
gcc.gcTerminated(pods)
}
gcc.gcOrphaned(pods)
gcc.gcUnscheduledTerminating(pods)
}
func isPodTerminated(pod *api.Pod) bool {
@@ -168,7 +169,7 @@ func (gcc *PodGCController) gcTerminated(pods []*api.Pod) {
wait.Wait()
}
// cleanupOrphanedPods deletes pods that are bound to nodes that don't exist.
// gcOrphaned deletes pods that are bound to nodes that don't exist.
func (gcc *PodGCController) gcOrphaned(pods []*api.Pod) {
glog.V(4).Infof("GC'ing orphaned")
@@ -183,7 +184,29 @@ func (gcc *PodGCController) gcOrphaned(pods []*api.Pod) {
if err := gcc.deletePod(pod.Namespace, pod.Name); err != nil {
utilruntime.HandleError(err)
} else {
glog.V(4).Infof("Forced deletion of oprhaned Pod %s succeeded", pod.Name)
glog.V(4).Infof("Forced deletion of orphaned Pod %s succeeded", pod.Name)
}
}
}
// gcUnscheduledTerminating deletes pods that are terminating and haven't been scheduled to a particular node.
func (gcc *PodGCController) gcUnscheduledTerminating(pods []*api.Pod) {
glog.V(4).Infof("GC'ing unscheduled pods which are terminating.")
for _, pod := range pods {
if pod.DeletionTimestamp == nil {
continue
}
if len(pod.Spec.NodeName) > 0 {
continue
}
glog.V(2).Infof("Found unscheduled terminating Pod %v not assigned to any Node. Deleting.", pod.Name)
if err := gcc.deletePod(pod.Namespace, pod.Name); err != nil {
utilruntime.HandleError(err)
} else {
glog.V(4).Infof("Forced deletion of unscheduled terminating Pod %s succeeded", pod.Name)
}
}
}