-
Notifications
You must be signed in to change notification settings - Fork 118
common: abort load on ENOSPC and output clear error #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| //go:build !windows | ||
|
|
||
| package libimage | ||
|
|
||
| import "syscall" | ||
|
|
||
| const ErrNoSpace = syscall.ENOSPC | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package libimage | ||
|
|
||
| import "syscall" | ||
|
|
||
| const ErrNoSpace = syscall.ERROR_DISK_FULL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,6 +110,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, ErrNoSpace) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| // %.0w makes err visible to error.Unwrap() without including any text | ||
| return nil, fmt.Errorf("no space left on device%.0w", err) | ||
| } | ||
|
|
||
|
zvenigorodsky marked this conversation as resolved.
|
||
| loadErrors = append(loadErrors, fmt.Errorf("%s: %v", transportName, err)) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import ( | |
| "io" | ||
| "io/fs" | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "runtime" | ||
| "strings" | ||
|
|
@@ -29,6 +30,7 @@ func (dst *unpackDestination) Close() error { | |
| return dst.root.Close() | ||
| } | ||
|
|
||
| const statusCodeENOSPC = 2 | ||
| // tarOptionsDescriptor is passed as an extra file | ||
| const tarOptionsDescriptor = 3 | ||
|
|
||
|
|
@@ -82,6 +84,9 @@ func untar() { | |
| } | ||
|
|
||
| if err := archive.Unpack(os.Stdin, dst, &options); err != nil { | ||
| if errors.Is(err, unix.ENOSPC) { | ||
| os.Exit(statusCodeENOSPC) | ||
| } | ||
| fatal(err) | ||
| } | ||
| // fully consume stdin in case it is zero padded | ||
|
|
@@ -155,6 +160,14 @@ func invokeUnpack(decompressedArchive io.Reader, dest *unpackDestination, option | |
| w.Close() | ||
|
|
||
| if err := cmd.Wait(); err != nil { | ||
| var exitErr *exec.ExitError | ||
| if errors.As(err, exitErr) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This already fails in |
||
| status := exitErr.ExitCode() | ||
| if status == statusCodeENOSPC { | ||
| 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, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per this comment, we probably still need to run the code below, to drain the output, on |
||
| // we need to exhaust `xz`'s output, otherwise the `xz` side will be | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.