summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-11-14 07:28:23 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2020-11-15 06:45:21 -0500
commitff65d6095dbb428bc8e3c560b305a20f526ae47c (patch)
tree84b9071f953751529ae48b9154e334ebc84fff12 /pkg
parent9fa09a83b30c5d9300eb40b3d50b405153b37f7a (diff)
downloadpodman-ff65d6095dbb428bc8e3c560b305a20f526ae47c.tar.gz
podman-ff65d6095dbb428bc8e3c560b305a20f526ae47c.tar.bz2
podman-ff65d6095dbb428bc8e3c560b305a20f526ae47c.zip
Wrap missing container errors with container ID
While playing around with podman system df, I saw that my container database was in bad state. Basically podman new about containers that were no longer in container/storage. The podman system df was just erroring out early stating "container does not exist" with no indicator of which container. This Patch wraps the podman system df errors to indicate which container does not exist. It also logs errors on containers that get into this state, but continues on to work on all containers. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/domain/infra/abi/system.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index 613c4a6d8..72fd98ac1 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -17,6 +17,7 @@ import (
"github.com/containers/podman/v2/pkg/rootless"
"github.com/containers/podman/v2/pkg/util"
"github.com/containers/podman/v2/utils"
+ "github.com/containers/storage"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -231,17 +232,25 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
dfContainers := make([]*entities.SystemDfContainerReport, 0, len(cons))
for _, c := range cons {
iid, _ := c.Image()
- conSize, err := c.RootFsSize()
+ state, err := c.State()
if err != nil {
- return nil, err
+ return nil, errors.Wrapf(err, "Failed to get state of container %s", c.ID())
}
- state, err := c.State()
+ conSize, err := c.RootFsSize()
if err != nil {
- return nil, err
+ if errors.Cause(err) == storage.ErrContainerUnknown {
+ logrus.Error(errors.Wrapf(err, "Failed to get root file system size of container %s", c.ID()))
+ } else {
+ return nil, errors.Wrapf(err, "Failed to get root file system size of container %s", c.ID())
+ }
}
rwsize, err := c.RWSize()
if err != nil {
- return nil, err
+ if errors.Cause(err) == storage.ErrContainerUnknown {
+ logrus.Error(errors.Wrapf(err, "Failed to get read/write size of container %s", c.ID()))
+ } else {
+ return nil, errors.Wrapf(err, "Failed to get read/write size of container %s", c.ID())
+ }
}
report := entities.SystemDfContainerReport{
ContainerID: c.ID(),