From fe137a8123f60f933204d21bf2ec16d4dd830044 Mon Sep 17 00:00:00 2001 From: Michail Kargakis Date: Fri, 10 Feb 2017 17:55:23 +0100 Subject: [PATCH] Remove redundant pod helper --- .../deployment/util/deployment_util.go | 25 ------------------- pkg/kubectl/rolling_updater.go | 2 +- test/e2e/framework/util.go | 4 +-- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/pkg/controller/deployment/util/deployment_util.go b/pkg/controller/deployment/util/deployment_util.go index 677fb578f53..1e62bdb69b0 100644 --- a/pkg/controller/deployment/util/deployment_util.go +++ b/pkg/controller/deployment/util/deployment_util.go @@ -786,31 +786,6 @@ func GetAvailableReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet return totalAvailableReplicas } -// IsPodAvailable return true if the pod is available. -// TODO: Remove this once we start using replica set status for calculating available pods -// for a deployment. -func IsPodAvailable(pod *v1.Pod, minReadySeconds int32, now time.Time) bool { - if !controller.IsPodActive(pod) { - return false - } - // Check if we've passed minReadySeconds since LastTransitionTime - // If so, this pod is ready - for _, c := range pod.Status.Conditions { - // we only care about pod ready conditions - if c.Type == v1.PodReady && c.Status == v1.ConditionTrue { - glog.V(4).Infof("Comparing pod %s/%s ready condition last transition time %s + minReadySeconds %d with now %s.", pod.Namespace, pod.Name, c.LastTransitionTime.String(), minReadySeconds, now.String()) - // 2 cases that this ready condition is valid (passed minReadySeconds, i.e. the pod is available): - // 1. minReadySeconds == 0, or - // 2. LastTransitionTime (is set) + minReadySeconds (>0) < current time - minReadySecondsDuration := time.Duration(minReadySeconds) * time.Second - if minReadySeconds == 0 || !c.LastTransitionTime.IsZero() && c.LastTransitionTime.Add(minReadySecondsDuration).Before(now) { - return true - } - } - } - return false -} - // IsRollingUpdate returns true if the strategy type is a rolling update. func IsRollingUpdate(deployment *extensions.Deployment) bool { return deployment.Spec.Strategy.Type == extensions.RollingUpdateDeploymentStrategyType diff --git a/pkg/kubectl/rolling_updater.go b/pkg/kubectl/rolling_updater.go index 427199c1db0..06be0b85279 100644 --- a/pkg/kubectl/rolling_updater.go +++ b/pkg/kubectl/rolling_updater.go @@ -429,7 +429,7 @@ func (r *RollingUpdater) readyPods(oldRc, newRc *api.ReplicationController, minR if v1Pod.DeletionTimestamp != nil { continue } - if !deploymentutil.IsPodAvailable(v1Pod, minReadySeconds, r.nowFn().Time) { + if !v1.IsPodAvailable(v1Pod, minReadySeconds, r.nowFn()) { continue } switch controller.Name { diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 8986ac2c601..2215c2d135e 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -3412,7 +3412,7 @@ func WaitForPodsReady(c clientset.Interface, ns, name string, minReadySeconds in return false, nil } for _, pod := range pods.Items { - if !deploymentutil.IsPodAvailable(&pod, int32(minReadySeconds), time.Now()) { + if !v1.IsPodAvailable(&pod, int32(minReadySeconds), metav1.Now()) { return false, nil } } @@ -3499,7 +3499,7 @@ func logPodsOfDeployment(c clientset.Interface, deployment *extensions.Deploymen } for _, pod := range podList.Items { availability := "not available" - if deploymentutil.IsPodAvailable(&pod, minReadySeconds, time.Now()) { + if v1.IsPodAvailable(&pod, minReadySeconds, metav1.Now()) { availability = "available" } Logf("Pod %s is %s:\n%+v", pod.Name, availability, pod)