summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-05-05 10:56:40 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-05-05 13:33:41 -0400
commitad27532b6c9c657c7aecaca4bcccb5baa6576839 (patch)
treedff3f5aed0e079d9aeebf3ae22e65e0f1c1cd0d3
parentfb6eca50ba9e2dc652da0c33c72db70ab9da85e9 (diff)
downloadpodman-ad27532b6c9c657c7aecaca4bcccb5baa6576839.tar.gz
podman-ad27532b6c9c657c7aecaca4bcccb5baa6576839.tar.bz2
podman-ad27532b6c9c657c7aecaca4bcccb5baa6576839.zip
Eliminate race condition on podman info
There is a potential of a race condition where a container is removed while podman is looking up information on the total containers. This can cause podman info to fail with an error "no such container". This change ignores the failure. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r--libpod/info.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/libpod/info.go b/libpod/info.go
index d7ed5bb16..4007e0ce7 100644
--- a/libpod/info.go
+++ b/libpod/info.go
@@ -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