Skip to content

Commit

Permalink
Merge pull request #11476 from vrothberg/fix-11392
Browse files Browse the repository at this point in the history
container inspect: improve error handling
  • Loading branch information
openshift-merge-robot authored Sep 8, 2021
2 parents 558ba1b + 6aa666a commit d68e429
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/domain/infra/abi/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []st
if options.Latest {
ctr, err := ic.Libpod.GetLatestContainer()
if err != nil {
if errors.Cause(err) == define.ErrNoSuchCtr {
if errors.Is(err, define.ErrNoSuchCtr) {
return nil, []error{errors.Wrapf(err, "no containers to inspect")}, nil
}
return nil, nil, err
Expand All @@ -397,7 +397,7 @@ func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []st
if err != nil {
// ErrNoSuchCtr is non-fatal, other errors will be
// treated as fatal.
if errors.Cause(err) == define.ErrNoSuchCtr {
if errors.Is(err, define.ErrNoSuchCtr) {
errs = append(errs, errors.Errorf("no such container %s", name))
continue
}
Expand All @@ -406,6 +406,12 @@ func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []st

inspect, err := ctr.Inspect(options.Size)
if err != nil {
// ErrNoSuchCtr is non-fatal, other errors will be
// treated as fatal.
if errors.Is(err, define.ErrNoSuchCtr) {
errs = append(errs, errors.Errorf("no such container %s", name))
continue
}
return nil, nil, err
}

Expand Down

0 comments on commit d68e429

Please sign in to comment.