Skip to content

Commit

Permalink
fix tests; convert IsPodActive to operate on *Pod
Browse files Browse the repository at this point in the history
  • Loading branch information
Chao Xu committed Aug 17, 2016
1 parent 3310837 commit 594234d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/controller_ref_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/controller_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion pkg/controller/controller_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/deployment/util/deployment_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 594234d

Please sign in to comment.