From 3916c009551a63fc3c8791f771cd58d457db56ac Mon Sep 17 00:00:00 2001 From: Matthias Bertschy Date: Wed, 5 May 2021 11:21:40 +0200 Subject: [PATCH] fix manual trigger of readinessProbe on startupProbe success --- pkg/kubelet/prober/prober_manager.go | 4 ++-- test/e2e/common/node/container_probe.go | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/kubelet/prober/prober_manager.go b/pkg/kubelet/prober/prober_manager.go index af6c723ec08..83532a313c3 100644 --- a/pkg/kubelet/prober/prober_manager.go +++ b/pkg/kubelet/prober/prober_manager.go @@ -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) diff --git a/test/e2e/common/node/container_probe.go b/test/e2e/common/node/container_probe.go index 3685f808687..efc0455ecce 100644 --- a/test/e2e/common/node/container_probe.go +++ b/test/e2e/common/node/container_probe.go @@ -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"}),