mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 13:31:52 +00:00
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.
This commit is contained in:
parent
3a5768a0ad
commit
d519741e1b
@ -2311,7 +2311,10 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName string, lo
|
|||||||
}
|
}
|
||||||
podStatus, found := kl.statusManager.GetPodStatus(podUID)
|
podStatus, found := kl.statusManager.GetPodStatus(podUID)
|
||||||
if !found {
|
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 {
|
if err := kl.validatePodPhase(&podStatus); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user