From 5edc0731225246748743e9c3a4bd4195fe95a8b8 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Tue, 11 Dec 2018 04:43:35 -0800 Subject: [PATCH] tests: getRestartDelay waits for the next Terminated state Kubelet might miss reporting the new Running state when restarting a pod after its backoff period expired, and thus, the pod will continue to remain in CrashLoopBackOff state, causing the "should cap back-off at MaxContainerBackOff" and "should have their auto-restart back-off timer reset on image update" tests to fail, since they're waiting the Pods to enter a Running state. Waiting for the next Terminated state instead of the next Running state is more reliable. Note that this adds 5 seconds to the restart delay due to the fact that the Container runs for 5 seconds (it's command is "sleep 5"), but it is within the test's expectations. --- test/e2e/common/pods.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/common/pods.go b/test/e2e/common/pods.go index b420e1e69a3..bf00db7aaba 100644 --- a/test/e2e/common/pods.go +++ b/test/e2e/common/pods.go @@ -116,8 +116,8 @@ func getRestartDelay(podClient *framework.PodClient, podName string, containerNa continue } - if status.State.Waiting == nil && status.State.Running != nil && status.LastTerminationState.Terminated != nil && status.State.Running.StartedAt.Time.After(beginTime) { - startedAt := status.State.Running.StartedAt.Time + if status.State.Waiting == nil && status.State.Terminated != nil && status.LastTerminationState.Terminated != nil && status.State.Terminated.StartedAt.Time.After(beginTime) { + startedAt := status.State.Terminated.StartedAt.Time finishedAt := status.LastTerminationState.Terminated.FinishedAt.Time framework.Logf("getRestartDelay: restartCount = %d, finishedAt=%s restartedAt=%s (%s)", status.RestartCount, finishedAt, startedAt, startedAt.Sub(finishedAt)) return startedAt.Sub(finishedAt), nil