From f00441d2ee4b4a61f52f5c5f71907068af01e12b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Th=C3=B6mmes?= Date: Thu, 22 Apr 2021 14:06:18 +0200 Subject: [PATCH] pkg/kubelet: Simplify status string generation on probes --- pkg/kubelet/kubelet.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 5eedf7c66e2..56717bd3d8a 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -1995,11 +1995,21 @@ func (kl *Kubelet) syncLoopIteration(configCh <-chan kubetypes.PodUpdate, handle case update := <-kl.readinessManager.Updates(): ready := update.Result == proberesults.Success kl.statusManager.SetContainerReadiness(update.PodUID, update.ContainerID, ready) - handleProbeSync(kl, update, handler, "readiness", map[bool]string{true: "ready", false: ""}[ready]) + + status := "" + if ready { + status = "ready" + } + handleProbeSync(kl, update, handler, "readiness", status) case update := <-kl.startupManager.Updates(): started := update.Result == proberesults.Success kl.statusManager.SetContainerStartup(update.PodUID, update.ContainerID, started) - handleProbeSync(kl, update, handler, "startup", map[bool]string{true: "started", false: "unhealthy"}[started]) + + status := "unhealthy" + if started { + status = "started" + } + handleProbeSync(kl, update, handler, "startup", status) case <-housekeepingCh: if !kl.sourcesReady.AllReady() { // If the sources aren't ready or volume manager has not yet synced the states,