summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2019-10-15 06:06:45 -0400
committerGitHub <noreply@github.com>2019-10-15 06:06:45 -0400
commit25572cefa8f16580c4a61af86cf2c41281e0300f (patch)
tree4a1bdf52c2e6ac4013075bc4f9846a29828453b2
parentb6b3acf2d74958957b40d557bf103072d120213e (diff)
parent17a7596af4f8e2898bd11945a5b3c085b882b021 (diff)
downloadpodman-25572cefa8f16580c4a61af86cf2c41281e0300f.tar.gz
podman-25572cefa8f16580c4a61af86cf2c41281e0300f.tar.bz2
podman-25572cefa8f16580c4a61af86cf2c41281e0300f.zip
Merge pull request #4262 from nalind/error-cause
Unwrap errors before comparing them
-rw-r--r--libpod/container_internal.go2
-rw-r--r--libpod/runtime_cstorage.go10
-rw-r--r--libpod/runtime_img.go2
3 files changed, 7 insertions, 7 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index e7f541c52..a7ac23f73 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -533,7 +533,7 @@ func (c *Container) teardownStorage() error {
// error - we wanted it gone, it is already gone.
// Potentially another tool using containers/storage already
// removed it?
- if err == storage.ErrNotAContainer || err == storage.ErrContainerUnknown {
+ if errors.Cause(err) == storage.ErrNotAContainer || errors.Cause(err) == storage.ErrContainerUnknown {
logrus.Warnf("Storage for container %s already removed", c.ID())
return nil
}
diff --git a/libpod/runtime_cstorage.go b/libpod/runtime_cstorage.go
index 47a91c881..2d523a7d2 100644
--- a/libpod/runtime_cstorage.go
+++ b/libpod/runtime_cstorage.go
@@ -68,7 +68,7 @@ func (r *Runtime) RemoveStorageContainer(idOrName string, force bool) error {
func (r *Runtime) removeStorageContainer(idOrName string, force bool) error {
targetID, err := r.store.Lookup(idOrName)
if err != nil {
- if err == storage.ErrLayerUnknown {
+ if errors.Cause(err) == storage.ErrLayerUnknown {
return errors.Wrapf(define.ErrNoSuchCtr, "no container with ID or name %q found", idOrName)
}
return errors.Wrapf(err, "error looking up container %q", idOrName)
@@ -78,7 +78,7 @@ func (r *Runtime) removeStorageContainer(idOrName string, force bool) error {
// So we can still error here.
ctr, err := r.store.Container(targetID)
if err != nil {
- if err == storage.ErrContainerUnknown {
+ if errors.Cause(err) == storage.ErrContainerUnknown {
return errors.Wrapf(define.ErrNoSuchCtr, "%q does not refer to a container", idOrName)
}
return errors.Wrapf(err, "error retrieving container %q", idOrName)
@@ -96,7 +96,7 @@ func (r *Runtime) removeStorageContainer(idOrName string, force bool) error {
if !force {
timesMounted, err := r.store.Mounted(ctr.ID)
if err != nil {
- if err == storage.ErrContainerUnknown {
+ if errors.Cause(err) == storage.ErrContainerUnknown {
// Container was removed from under us.
// It's gone, so don't bother erroring.
logrus.Warnf("Storage for container %s already removed", ctr.ID)
@@ -109,7 +109,7 @@ func (r *Runtime) removeStorageContainer(idOrName string, force bool) error {
}
} else {
if _, err := r.store.Unmount(ctr.ID, true); err != nil {
- if err == storage.ErrContainerUnknown {
+ if errors.Cause(err) == storage.ErrContainerUnknown {
// Container again gone, no error
logrus.Warnf("Storage for container %s already removed", ctr.ID)
return nil
@@ -119,7 +119,7 @@ func (r *Runtime) removeStorageContainer(idOrName string, force bool) error {
}
if err := r.store.DeleteContainer(ctr.ID); err != nil {
- if err == storage.ErrContainerUnknown {
+ if errors.Cause(err) == storage.ErrContainerUnknown {
// Container again gone, no error
logrus.Warnf("Storage for container %s already removed", ctr.ID)
return nil
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index 8cc501629..35c0cdfb9 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -69,7 +69,7 @@ func (r *Runtime) RemoveImage(ctx context.Context, img *image.Image, force bool)
// the image. we figure out which repotag the user is trying to refer
// to and untag it.
repoName, err := img.MatchRepoTag(img.InputName)
- if hasChildren && err == image.ErrRepoTagNotFound {
+ if hasChildren && errors.Cause(err) == image.ErrRepoTagNotFound {
return "", errors.Errorf("unable to delete %q (cannot be forced) - image has dependent child images", img.ID())
}
if err != nil {