summaryrefslogtreecommitdiff
path: root/pkg/ps
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2021-09-30 16:07:08 -0700
committerJhon Honce <jhonce@redhat.com>2021-10-01 11:17:15 -0700
commitc67593df1240adbbd425642740f321c3ca9c6654 (patch)
tree7c727815f684a78f574ac6e641416dc78d8e5ec8 /pkg/ps
parente9d8524af5122314e47385299bf9ae3d0b000096 (diff)
downloadpodman-c67593df1240adbbd425642740f321c3ca9c6654.tar.gz
podman-c67593df1240adbbd425642740f321c3ca9c6654.tar.bz2
podman-c67593df1240adbbd425642740f321c3ca9c6654.zip
[NO TESTS NEEDED] Ignore removed containers
* Ignore condition when containers are removed while listing them for ps output. No tests added at this time as they would create a race condition for CI. * Updated godocs See https://github.com/containers/podman/issues/11810 for reproducer. Fixes #11810 Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/ps')
-rw-r--r--pkg/ps/ps.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/pkg/ps/ps.go b/pkg/ps/ps.go
index 0f154c524..69ac9c215 100644
--- a/pkg/ps/ps.go
+++ b/pkg/ps/ps.go
@@ -15,6 +15,7 @@ import (
"github.com/containers/podman/v3/pkg/domain/filters"
psdefine "github.com/containers/podman/v3/pkg/ps/define"
"github.com/containers/storage"
+ "github.com/containers/storage/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -63,10 +64,14 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp
}
for _, con := range cons {
listCon, err := ListContainerBatch(runtime, con, options)
- if err != nil {
+ switch {
+ case errors.Cause(err) == define.ErrNoSuchCtr:
+ continue
+ case err != nil:
return nil, err
+ default:
+ pss = append(pss, listCon)
}
- pss = append(pss, listCon)
}
if options.All && options.External {
@@ -89,7 +94,7 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp
return pss, nil
}
-// GetExternalContainerLists returns list of external containers for e.g created by buildah
+// GetExternalContainerLists returns list of external containers for e.g. created by buildah
func GetExternalContainerLists(runtime *libpod.Runtime) ([]entities.ListContainer, error) {
var (
pss = []entities.ListContainer{}
@@ -102,15 +107,19 @@ func GetExternalContainerLists(runtime *libpod.Runtime) ([]entities.ListContaine
for _, con := range externCons {
listCon, err := ListStorageContainer(runtime, con)
- if err != nil {
+ switch {
+ case errors.Cause(err) == types.ErrLoadError:
+ continue
+ case err != nil:
return nil, err
+ default:
+ pss = append(pss, listCon)
}
- pss = append(pss, listCon)
}
return pss, nil
}
-// BatchContainerOp is used in ps to reduce performance hits by "batching"
+// ListContainerBatch is used in ps to reduce performance hits by "batching"
// locks.
func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities.ContainerListOptions) (entities.ListContainer, error) {
var (