-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backoff restart container with liveness probing failure #22241
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ import ( | |
"bytes" | ||
"fmt" | ||
"io" | ||
"math" | ||
"strconv" | ||
"strings" | ||
"time" | ||
|
@@ -199,7 +198,7 @@ func getRestartDelay(c *client.Client, pod *api.Pod, ns string, name string, con | |
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 | ||
finishedAt := status.LastTerminationState.Terminated.FinishedAt.Time | ||
Logf("getRestartDelay: finishedAt=%s restartedAt=%s (%s)", finishedAt, startedAt, startedAt.Sub(finishedAt)) | ||
Logf("getRestartDelay: restartCount = %d, finishedAt=%s restartedAt=%s (%s)", status.RestartCount, finishedAt, startedAt, startedAt.Sub(finishedAt)) | ||
return startedAt.Sub(finishedAt), nil | ||
} | ||
} | ||
|
@@ -982,46 +981,6 @@ var _ = Describe("Pods", func() { | |
} | ||
}) | ||
|
||
It("should not back-off restarting a container on LivenessProbe failure [Serial]", func() { | ||
podClient := framework.Client.Pods(framework.Namespace.Name) | ||
podName := "pod-back-off-liveness" | ||
containerName := "back-off-liveness" | ||
pod := &api.Pod{ | ||
ObjectMeta: api.ObjectMeta{ | ||
Name: podName, | ||
Labels: map[string]string{"test": "liveness"}, | ||
}, | ||
Spec: api.PodSpec{ | ||
Containers: []api.Container{ | ||
{ | ||
Name: containerName, | ||
Image: "gcr.io/google_containers/busybox:1.24", | ||
Command: []string{"/bin/sh", "-c", "echo ok >/tmp/health; sleep 5; rm -rf /tmp/health; sleep 600"}, | ||
LivenessProbe: &api.Probe{ | ||
Handler: api.Handler{ | ||
Exec: &api.ExecAction{ | ||
Command: []string{"cat", "/tmp/health"}, | ||
}, | ||
}, | ||
InitialDelaySeconds: 5, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
defer func() { | ||
By("deleting the pod") | ||
podClient.Delete(pod.Name, api.NewDeleteOptions(0)) | ||
}() | ||
|
||
delay1, delay2 := startPodAndGetBackOffs(framework, pod, podName, containerName, buildBackOffDuration) | ||
|
||
if math.Abs(float64(delay2-delay1)) > float64(syncLoopFrequency) { | ||
Failf("back-off increasing on LivenessProbe failure delay1=%s delay2=%s", delay1, delay2) | ||
} | ||
}) | ||
|
||
// Slow issue #19027 (20 mins) | ||
It("should cap back-off at MaxContainerBackOff [Slow]", func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you removing this test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I discussed with @dchen1107 , and we didn't quite understand why kubelet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this test is because it tests a wrong thing. |
||
podClient := framework.Client.Pods(framework.Namespace.Name) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is this check no longer required? -
!containerStatus.FinishedAt.IsZero()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the original PR,
FinishedAt.IsZero()
is used to check whether container status is found in the previous loop. I kept it before just in case, but in fact it is not required now. :)