From 594234d61c4e6c7dd29be1a575d88aa899478cc6 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 17 Aug 2016 13:05:37 -0700 Subject: [PATCH] fix tests; convert IsPodActive to operate on *Pod --- pkg/controller/controller_ref_manager.go | 2 +- pkg/controller/controller_utils.go | 4 ++-- pkg/controller/controller_utils_test.go | 6 +++++- pkg/controller/deployment/util/deployment_util.go | 2 +- test/e2e/framework/util.go | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/controller/controller_ref_manager.go b/pkg/controller/controller_ref_manager.go index f2dcae5fd73..52a8667f209 100644 --- a/pkg/controller/controller_ref_manager.go +++ b/pkg/controller/controller_ref_manager.go @@ -59,7 +59,7 @@ func (m *PodControllerRefManager) Classify(pods []*api.Pod) ( controlledDoesNotMatch []*api.Pod) { for i := range pods { pod := pods[i] - if !IsPodActive(*pod) { + if !IsPodActive(pod) { glog.V(4).Infof("Ignoring inactive pod %v/%v in state %v, deletion time %v", pod.Namespace, pod.Name, pod.Status.Phase, pod.DeletionTimestamp) continue diff --git a/pkg/controller/controller_utils.go b/pkg/controller/controller_utils.go index 2ccccfb07de..81930422eba 100644 --- a/pkg/controller/controller_utils.go +++ b/pkg/controller/controller_utils.go @@ -686,7 +686,7 @@ func maxContainerRestarts(pod *api.Pod) int { func FilterActivePods(pods []*api.Pod) []*api.Pod { var result []*api.Pod for _, p := range pods { - if IsPodActive(*p) { + if IsPodActive(p) { result = append(result, p) } else { glog.V(4).Infof("Ignoring inactive pod %v/%v in state %v, deletion time %v", @@ -696,7 +696,7 @@ func FilterActivePods(pods []*api.Pod) []*api.Pod { return result } -func IsPodActive(p api.Pod) bool { +func IsPodActive(p *api.Pod) bool { return api.PodSucceeded != p.Status.Phase && api.PodFailed != p.Status.Phase && p.DeletionTimestamp == nil diff --git a/pkg/controller/controller_utils_test.go b/pkg/controller/controller_utils_test.go index a605fb658f9..92bf9b496c3 100644 --- a/pkg/controller/controller_utils_test.go +++ b/pkg/controller/controller_utils_test.go @@ -287,7 +287,11 @@ func TestActivePodFiltering(t *testing.T) { expectedNames.Insert(pod.Name) } - got := FilterActivePods(podList.Items) + var podPointers []*api.Pod + for i := range podList.Items { + podPointers = append(podPointers, &podList.Items[i]) + } + got := FilterActivePods(podPointers) gotNames := sets.NewString() for _, pod := range got { gotNames.Insert(pod.Name) diff --git a/pkg/controller/deployment/util/deployment_util.go b/pkg/controller/deployment/util/deployment_util.go index 083f8aef1ba..d7e43508f33 100644 --- a/pkg/controller/deployment/util/deployment_util.go +++ b/pkg/controller/deployment/util/deployment_util.go @@ -633,7 +633,7 @@ func countAvailablePods(pods []api.Pod, minReadySeconds int32) int32 { // IsPodAvailable return true if the pod is available. func IsPodAvailable(pod *api.Pod, minReadySeconds int32, now time.Time) bool { - if !controller.IsPodActive(*pod) { + if !controller.IsPodActive(pod) { return false } // Check if we've passed minReadySeconds since LastTransitionTime diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 6dc37d74ef6..1931c92c219 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -3166,7 +3166,7 @@ func waitForPodsInactive(ps *PodStore, interval, timeout time.Duration) error { return wait.PollImmediate(interval, timeout, func() (bool, error) { pods := ps.List() for _, pod := range pods { - if controller.IsPodActive(*pod) { + if controller.IsPodActive(pod) { return false, nil } }