Merge pull request #16327 from tyler92/fix-deadlock-pod-ps-inspect

Fix deadlock between 'podman ps' and 'container inspect' commands
This commit is contained in:
OpenShift Merge Robot
2022-10-28 04:40:23 -04:00
committed by GitHub

View File

@ -581,20 +581,15 @@ func (p *Pod) Status() (map[string]define.ContainerStatus, error) {
}
func containerStatusFromContainers(allCtrs []*Container) (map[string]define.ContainerStatus, error) {
// We need to lock all the containers
for _, ctr := range allCtrs {
ctr.lock.Lock()
defer ctr.lock.Unlock()
}
// Now that all containers are locked, get their status
status := make(map[string]define.ContainerStatus, len(allCtrs))
for _, ctr := range allCtrs {
if err := ctr.syncContainer(); err != nil {
state, err := ctr.State()
if err != nil {
return nil, err
}
status[ctr.ID()] = ctr.state.State
status[ctr.ID()] = state
}
return status, nil