Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions common/libimage/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"go.podman.io/image/v5/transports"
"go.podman.io/image/v5/types"
"go.podman.io/storage/pkg/fileutils"
"go.podman.io/common/pkg/config"
)

type LoadOptions struct {
Expand Down Expand Up @@ -110,6 +111,12 @@ func (r *Runtime) Load(ctx context.Context, path string, options *LoadOptions) (
return loadedImages, err
}
logrus.Debugf("Error loading %s (%s): %v", path, transportName, err)

if errors.Is(err, config.ErrDiskFull) {
// %.0w makes e visible to error.Unwrap() without including any text
return nil, fmt.Errorf("no space left on device%.0w", err)
}

loadErrors = append(loadErrors, fmt.Errorf("%s: %v", transportName, err))
}

Expand Down
3 changes: 3 additions & 0 deletions common/pkg/config/config_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ package config

import (
"path/filepath"
"golang.org/x/sys/unix"
)

var ErrDiskFull = unix.ENOSPC

func safeEvalSymlinks(filePath string) (string, error) {
return filepath.EvalSymlinks(filePath)
}
3 changes: 3 additions & 0 deletions common/pkg/config/config_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ package config
import (
"io/fs"
"os"
"syscall"
"path/filepath"
)

var ErrDiskFull = syscall.Errno(112)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I don't handle the Winodws error, I just added this for the build to work, tell me if I should move it or how can I approach testing it for Windows


const (
// DefaultSignaturePolicyPath is the default value for the
// policy.json file.
Expand Down
11 changes: 11 additions & 0 deletions storage/pkg/chrootarchive/archive_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"io/fs"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -82,6 +83,9 @@ func untar() {
}

if err := archive.Unpack(os.Stdin, dst, &options); err != nil {
if errors.Is(err, unix.ENOSPC) {
os.Exit(2)
}
fatal(err)
}
// fully consume stdin in case it is zero padded
Expand Down Expand Up @@ -155,6 +159,13 @@ func invokeUnpack(decompressedArchive io.Reader, dest *unpackDestination, option
w.Close()

if err := cmd.Wait(); err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
status := exitErr.ExitCode()
if status == 2 {
return unix.ENOSPC
}
}

errorOut := fmt.Errorf("unpacking failed (error: %w; output: %s)", err, output)
// when `xz -d -c -q | storage-untar ...` failed on storage-untar side,
// we need to exhaust `xz`'s output, otherwise the `xz` side will be
Expand Down