addressing comments.

This commit is contained in:
Anirudh 2016-10-27 13:30:04 -07:00
parent c0d116c419
commit 1ae1a19e7b
2 changed files with 7 additions and 8 deletions

View File

@ -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)
}
}
}

View File

@ -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)
}
}
}