From 64d42542174d22968c424ba4b976b5e1055647cd Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Tue, 16 Jun 2020 10:25:42 -0700 Subject: [PATCH] Pods which have not "started" can not be "ready" Before this commit, containers which have both a `startupProbe` and a `readinessProbe` are marked as `ready=false` during stratup, but containers which have only a `startupProbe` are marked `ready=true`. This doesn't make sense. This commit only considers readiness if the container is considered to have "started", which leaves `ready=false` while starting up. --- pkg/kubelet/prober/prober_manager.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pkg/kubelet/prober/prober_manager.go b/pkg/kubelet/prober/prober_manager.go index 02cdeba6cca..bab65ceb677 100644 --- a/pkg/kubelet/prober/prober_manager.go +++ b/pkg/kubelet/prober/prober_manager.go @@ -235,18 +235,6 @@ func (m *manager) CleanupPods(desiredPods map[types.UID]sets.Empty) { func (m *manager) UpdatePodStatus(podUID types.UID, podStatus *v1.PodStatus) { for i, c := range podStatus.ContainerStatuses { - 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 { - // The check whether there is a probe which hasn't run yet. - _, exists := m.getWorker(podUID, c.Name, readiness) - ready = !exists - } - podStatus.ContainerStatuses[i].Ready = ready - var started bool if c.State.Running == nil { started = false @@ -261,6 +249,20 @@ func (m *manager) UpdatePodStatus(podUID types.UID, podStatus *v1.PodStatus) { started = !exists } podStatus.ContainerStatuses[i].Started = &started + + if started { + 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 { + // The check whether there is a probe which hasn't run yet. + _, exists := m.getWorker(podUID, c.Name, readiness) + ready = !exists + } + podStatus.ContainerStatuses[i].Ready = ready + } } // init containers are ready if they have exited with success or if a readiness probe has // succeeded.