Merge pull request #6091 from rhatdan/v2

Eliminate race condition on podman info
This commit is contained in:
OpenShift Merge Robot 2020-05-06 22:00:32 +02:00 committed by GitHub
commit 062c7b8a94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -198,9 +198,15 @@ func (r *Runtime) getContainerStoreInfo() (define.ContainerStore, error) {
if err != nil {
return cs, err
}
cs.Number = len(cons)
for _, con := range cons {
state, err := con.State()
if err != nil {
if errors.Cause(err) == define.ErrNoSuchCtr {
// container was probably removed
cs.Number--
continue
}
return cs, err
}
switch state {
@ -212,7 +218,6 @@ func (r *Runtime) getContainerStoreInfo() (define.ContainerStore, error) {
stopped += 1
}
}
cs.Number = len(cons)
cs.Paused = paused
cs.Stopped = stopped
cs.Running = running