Skip to content

Commit

Permalink
podman load: fix error handling
Browse files Browse the repository at this point in the history
Make sure to properly return loading errors and to set the exit code
accordingly.

Fixes: containers#9672
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Mar 9, 2021
1 parent 36ec835 commit 930bec4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libpod/runtime_img.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io
} {
src, err := referenceFn()
if err == nil && src != nil {
if newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer); err == nil {
newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer)
if err == nil {
return getImageNames(newImages), nil
}
saveErr = err
Expand Down
7 changes: 7 additions & 0 deletions test/system/120-load.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ verify_iid_and_name() {
is "$new_img_name" "$1" "Name & tag of restored image"
}

@test "podman load invalid file" {
# Regression test for #9672 to make sure invalid input yields errors.
invalid=$PODMAN_TMPDIR/invalid
echo "I am an invalid file and should cause a podman-load error" > $invalid
run_podman 125 load -i $invalid
}

@test "podman save to pipe and load" {
# Generate a random name and tag (must be lower-case)
local random_name=x0$(random_string 12 | tr A-Z a-z)
Expand Down

0 comments on commit 930bec4

Please sign in to comment.