Ignore "no such container" error when generating pod status

This allows the pod continue to sync if one container in a corrupt state.
This commit is contained in:
Yu-Ju Hong
2016-03-04 17:33:23 -08:00
parent 3e948a6ee0
commit b1a6ee26ef
2 changed files with 66 additions and 2 deletions

View File

@@ -2110,10 +2110,22 @@ func (dm *DockerManager) GetPodStatus(uid types.UID, name, namespace string) (*k
if dockerName.PodUID != uid {
continue
}
result, ip, err := dm.inspectContainer(c.ID, name, namespace)
if err != nil {
return podStatus, err
if _, ok := err.(*docker.NoSuchContainer); ok {
// https://github.com/kubernetes/kubernetes/issues/22541
// Sometimes when docker's state is corrupt, a container can be listed
// but couldn't be inspected. We fake a status for this container so
// that we can still return a status for the pod to sync.
result = &kubecontainer.ContainerStatus{
ID: kubecontainer.DockerID(c.ID).ContainerID(),
Name: dockerName.ContainerName,
State: kubecontainer.ContainerStateUnknown,
}
glog.Errorf("Unable to inspect container %q: %v", c.ID, err)
} else {
return podStatus, err
}
}
containerStatuses = append(containerStatuses, result)
if ip != "" {