mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #1262 from dchen1107/restart
Fix PodInfo to include last terminated container info when calling
This commit is contained in:
commit
c378b7b022
@ -180,14 +180,14 @@ func getRecentDockerContainersWithNameAndUUID(client DockerInterface, podFullNam
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrNoContainersInPod is returned when there are no running containers for a given pod
|
// ErrNoContainersInPod is returned when there are no containers for a given pod
|
||||||
var ErrNoContainersInPod = errors.New("no containers exist for this pod")
|
var ErrNoContainersInPod = errors.New("no containers exist for this pod")
|
||||||
|
|
||||||
// GetDockerPodInfo returns docker info for all containers in the pod/manifest.
|
// GetDockerPodInfo returns docker info for all containers in the pod/manifest.
|
||||||
func getDockerPodInfo(client DockerInterface, podFullName, uuid string) (api.PodInfo, error) {
|
func getDockerPodInfo(client DockerInterface, podFullName, uuid string) (api.PodInfo, error) {
|
||||||
info := api.PodInfo{}
|
info := api.PodInfo{}
|
||||||
|
|
||||||
containers, err := client.ListContainers(docker.ListContainersOptions{})
|
containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -200,6 +200,11 @@ func getDockerPodInfo(client DockerInterface, podFullName, uuid string) (api.Pod
|
|||||||
if uuid != "" && dockerUUID != uuid {
|
if uuid != "" && dockerUUID != uuid {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// We assume docker return us a list of containers in time order
|
||||||
|
if _, ok := info[dockerContainerName]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
inspectResult, err := client.InspectContainer(value.ID)
|
inspectResult, err := client.InspectContainer(value.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user