Merge pull request #101738 from matthyx/deflake-startupprobe

fix manual trigger of readinessProbe on startupProbe success
This commit is contained in:
Kubernetes Prow Robot 2021-06-03 14:34:42 -07:00 committed by GitHub
commit 9f7c9c322f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -241,8 +241,8 @@ func (m *manager) UpdatePodStatus(podUID types.UID, podStatus *v1.PodStatus) {
var ready bool
if c.State.Running == nil {
ready = false
} else if result, ok := m.readinessManager.Get(kubecontainer.ParseContainerID(c.ContainerID)); ok {
ready = result == results.Success
} else if result, ok := m.readinessManager.Get(kubecontainer.ParseContainerID(c.ContainerID)); ok && result == results.Success {
ready = true
} else {
// The check whether there is a probe which hasn't run yet.
w, exists := m.getWorker(podUID, c.Name, readiness)

View File

@ -398,11 +398,14 @@ var _ = SIGDescribe("Probing container", func() {
Description: A Pod is created with startup and readiness probes. The Container is started by creating /tmp/startup after 45 seconds, delaying the ready state by this amount of time. This is similar to the "Pod readiness probe, with initial delay" test.
*/
ginkgo.It("should be ready immediately after startupProbe succeeds", func() {
cmd := []string{"/bin/sh", "-c", "echo ok >/tmp/health; sleep 10; echo ok >/tmp/startup; sleep 600"}
// Probe workers sleep at Kubelet start for a random time which is at most PeriodSeconds
// this test requires both readiness and startup workers running before updating statuses
// to avoid flakes, ensure sleep before startup (22s) > readinessProbe.PeriodSeconds
cmd := []string{"/bin/sh", "-c", "echo ok >/tmp/health; sleep 22; echo ok >/tmp/startup; sleep 600"}
readinessProbe := &v1.Probe{
Handler: execHandler([]string{"/bin/cat", "/tmp/health"}),
InitialDelaySeconds: 0,
PeriodSeconds: 60,
PeriodSeconds: 20,
}
startupProbe := &v1.Probe{
Handler: execHandler([]string{"/bin/cat", "/tmp/startup"}),