Skip to content

Commit 64d4254

Browse files
committed
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.
1 parent 19d2200 commit 64d4254

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

pkg/kubelet/prober/prober_manager.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,6 @@ func (m *manager) CleanupPods(desiredPods map[types.UID]sets.Empty) {
235235

236236
func (m *manager) UpdatePodStatus(podUID types.UID, podStatus *v1.PodStatus) {
237237
for i, c := range podStatus.ContainerStatuses {
238-
var ready bool
239-
if c.State.Running == nil {
240-
ready = false
241-
} else if result, ok := m.readinessManager.Get(kubecontainer.ParseContainerID(c.ContainerID)); ok {
242-
ready = result == results.Success
243-
} else {
244-
// The check whether there is a probe which hasn't run yet.
245-
_, exists := m.getWorker(podUID, c.Name, readiness)
246-
ready = !exists
247-
}
248-
podStatus.ContainerStatuses[i].Ready = ready
249-
250238
var started bool
251239
if c.State.Running == nil {
252240
started = false
@@ -261,6 +249,20 @@ func (m *manager) UpdatePodStatus(podUID types.UID, podStatus *v1.PodStatus) {
261249
started = !exists
262250
}
263251
podStatus.ContainerStatuses[i].Started = &started
252+
253+
if started {
254+
var ready bool
255+
if c.State.Running == nil {
256+
ready = false
257+
} else if result, ok := m.readinessManager.Get(kubecontainer.ParseContainerID(c.ContainerID)); ok {
258+
ready = result == results.Success
259+
} else {
260+
// The check whether there is a probe which hasn't run yet.
261+
_, exists := m.getWorker(podUID, c.Name, readiness)
262+
ready = !exists
263+
}
264+
podStatus.ContainerStatuses[i].Ready = ready
265+
}
264266
}
265267
// init containers are ready if they have exited with success or if a readiness probe has
266268
// succeeded.

0 commit comments

Comments
 (0)