diff --git a/pkg/controller/podgc/gc_controller.go b/pkg/controller/podgc/gc_controller.go index 27bad9ce617..dea856ca97d 100644 --- a/pkg/controller/podgc/gc_controller.go +++ b/pkg/controller/podgc/gc_controller.go @@ -184,7 +184,7 @@ 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 orphaned Pod %s succeeded", pod.Name) + glog.V(0).Infof("Forced deletion of orphaned Pod %s succeeded", pod.Name) } } } @@ -194,11 +194,7 @@ 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 { + if pod.DeletionTimestamp == nil || len(pod.Spec.NodeName) > 0 { continue } @@ -206,7 +202,7 @@ func (gcc *PodGCController) gcUnscheduledTerminating(pods []*api.Pod) { 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) + glog.V(0).Infof("Forced deletion of unscheduled terminating Pod %s succeeded", pod.Name) } } } diff --git a/pkg/controller/podgc/gc_controller_test.go b/pkg/controller/podgc/gc_controller_test.go index 418db6110d9..02558a80eb0 100644 --- a/pkg/controller/podgc/gc_controller_test.go +++ b/pkg/controller/podgc/gc_controller_test.go @@ -226,10 +226,12 @@ func TestGCUnscheduledTerminating(t *testing.T) { } testCases := []struct { + name string pods []nameToPhase deletedPodNames sets.String }{ { + name: "Unscheduled pod in any phase must be deleted", pods: []nameToPhase{ {name: "a", phase: api.PodFailed, deletionTimeStamp: &unversioned.Time{}, nodeName: ""}, {name: "b", phase: api.PodSucceeded, deletionTimeStamp: &unversioned.Time{}, nodeName: ""}, @@ -238,6 +240,7 @@ func TestGCUnscheduledTerminating(t *testing.T) { deletedPodNames: sets.NewString("a", "b", "c"), }, { + name: "Scheduled pod in any phase must not be deleted", pods: []nameToPhase{ {name: "a", phase: api.PodFailed, deletionTimeStamp: nil, nodeName: ""}, {name: "b", phase: api.PodSucceeded, deletionTimeStamp: nil, nodeName: "node"}, @@ -292,7 +295,7 @@ func TestGCUnscheduledTerminating(t *testing.T) { pass = false } if !pass { - t.Errorf("[%v]pod's deleted expected and actual did not match.\n\texpected: %v\n\tactual: %v", i, test.deletedPodNames, deletedPodNames) + t.Errorf("[%v]pod's deleted expected and actual did not match.\n\texpected: %v\n\tactual: %v, test: %v", i, test.deletedPodNames, deletedPodNames, test.name) } } }