Skip to content

Commit

Permalink
podman mount: some better error wrapping
Browse files Browse the repository at this point in the history
As shown in containers#23671 these functions can return the raw error without any
useful context to the user which makes it hard to understand where
things went wrong. Simply add some context to some error paths here.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Sep 27, 2024
1 parent 5c3019e commit 1950555
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libpod/runtime_ctr.go
Original file line number Diff line number Diff line change
Expand Up @@ -1412,13 +1412,13 @@ func (r *Runtime) IsStorageContainerMounted(id string) (bool, string, error) {

mountCnt, err := r.storageService.MountedContainerImage(id)
if err != nil {
return false, "", err
return false, "", fmt.Errorf("get mount count of container: %w", err)
}
mounted := mountCnt > 0
if mounted {
path, err = r.storageService.GetMountpoint(id)
if err != nil {
return false, "", err
return false, "", fmt.Errorf("get container mount point: %w", err)
}
}
return mounted, path, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/domain/infra/abi/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin
if errors.Is(err, types.ErrContainerUnknown) || errors.Is(err, types.ErrLayerUnknown) || errors.Is(err, define.ErrCtrExists) {
continue
}
return nil, err
return nil, fmt.Errorf("check if storage container is mounted: %w", err)
}

var name string
Expand Down Expand Up @@ -1449,7 +1449,7 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin
errors.Is(err, define.ErrCtrRemoved) {
continue
}
return nil, err
return nil, fmt.Errorf("check if container is mounted: %w", err)
}

if mounted {
Expand Down

0 comments on commit 1950555

Please sign in to comment.