mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 23:37:01 +00:00
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.
This commit is contained in:
parent
0914272a42
commit
5edc073122
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user