From 952e6c64b68b0c3bdcfb46376bd340d923dc065f Mon Sep 17 00:00:00 2001 From: Tomas Nozicka Date: Sat, 24 Feb 2018 14:29:53 +0100 Subject: [PATCH] Fix Deployment with Recreate strategy not to wait on Pods in terminal phase --- pkg/controller/deployment/recreate.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/controller/deployment/recreate.go b/pkg/controller/deployment/recreate.go index 4d2f2337d7a..b6f01ef5460 100644 --- a/pkg/controller/deployment/recreate.go +++ b/pkg/controller/deployment/recreate.go @@ -104,8 +104,19 @@ func oldPodsRunning(newRS *extensions.ReplicaSet, oldRSs []*extensions.ReplicaSe if newRS != nil && newRS.UID == rsUID { continue } - if len(podList.Items) > 0 { - return true + for _, pod := range podList.Items { + switch pod.Status.Phase { + case v1.PodFailed, v1.PodSucceeded: + // Don't count pods in terminal state. + continue + case v1.PodUnknown: + // This happens in situation like when the node is temporarily disconnected from the cluster. + // If we can't be sure that the pod is not running, we have to count it. + return true + default: + // Pod is not in terminal phase. + return true + } } } return false