From d519741e1b59d7d87264aaf7d478534dbfa15864 Mon Sep 17 00:00:00 2001 From: kargakis Date: Fri, 6 Nov 2015 21:15:40 +0100 Subject: [PATCH] kubelet: Fallback to api server for pod status This commit fixes getting the logs from complete/failed pods after a kubelet restart by falling back to the api server in case we fail to resolve the pod status using the status cache. --- pkg/kubelet/kubelet.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index b2e063b1c92..c9ba8076fbf 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -2311,7 +2311,10 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName string, lo } podStatus, found := kl.statusManager.GetPodStatus(podUID) if !found { - return fmt.Errorf("failed to get status for pod %q in namespace %q", name, namespace) + // If there is no cached status, use the status from the + // apiserver. This is useful if kubelet has recently been + // restarted. + podStatus = pod.Status } if err := kl.validatePodPhase(&podStatus); err != nil {