From 8816006d1e11e1a45ed2fdc4793ef48a444ed8e8 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Fri, 7 Jan 2022 12:16:00 -0800 Subject: [PATCH 1/3] Fix followup items from errors replacement Signed-off-by: Derek McGowan --- mount/temp.go | 2 +- remotes/handlers.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mount/temp.go b/mount/temp.go index 5ea82c8ec..13eedaf03 100644 --- a/mount/temp.go +++ b/mount/temp.go @@ -32,7 +32,7 @@ var tempMountLocation = getTempDir() func WithTempMount(ctx context.Context, mounts []Mount, f func(root string) error) (err error) { root, uerr := os.MkdirTemp(tempMountLocation, "containerd-mount") if uerr != nil { - return fmt.Errorf("failed to create temp dir: %w", err) + return fmt.Errorf("failed to create temp dir: %w", uerr) } // We use Remove here instead of RemoveAll. // The RemoveAll will delete the temp dir and all children it contains. diff --git a/remotes/handlers.go b/remotes/handlers.go index 9ec54209f..f03caf2bf 100644 --- a/remotes/handlers.go +++ b/remotes/handlers.go @@ -244,7 +244,7 @@ func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, st if (manifestStack[i].MediaType == ocispec.MediaTypeImageIndex || manifestStack[i].MediaType == images.MediaTypeDockerSchema2ManifestList) && errors.Unwrap(err) != nil && strings.Contains(errors.Unwrap(err).Error(), "400 Bad Request") { - return fmt.Errorf("manifest list/index references to blobs and/or manifests are missing in your target registry: %w ", err) + return fmt.Errorf("manifest list/index references to blobs and/or manifests are missing in your target registry: %w", err) } return err } From 0c2c289d4c833e3f54d515f98c7e1fc0f64655e6 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Fri, 7 Jan 2022 12:19:23 -0800 Subject: [PATCH 2/3] Fix seek error used without nil check Signed-off-by: Derek McGowan --- content/helpers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/content/helpers.go b/content/helpers.go index fb078d46e..3ec1ffce0 100644 --- a/content/helpers.go +++ b/content/helpers.go @@ -212,6 +212,9 @@ func seekReader(r io.Reader, offset, size int64) (io.Reader, error) { if ok { nn, err := seeker.Seek(offset, io.SeekStart) if nn != offset { + if err == nil { + err = fmt.Errorf("unexpected seek location without seek error") + } return nil, fmt.Errorf("failed to seek to offset %v: %w", offset, err) } From 48c7529de2003a3b3cdfc6119796663fde32c681 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Fri, 7 Jan 2022 12:23:18 -0800 Subject: [PATCH 3/3] Fix incorrect error wrapped when closing ingest file Signed-off-by: Derek McGowan --- content/local/writer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/local/writer.go b/content/local/writer.go index 2f5f8dcf4..b187e524c 100644 --- a/content/local/writer.go +++ b/content/local/writer.go @@ -103,7 +103,7 @@ func (w *writer) Commit(ctx context.Context, size int64, expected digest.Digest, return fmt.Errorf("stat on ingest file failed: %w", err) } if closeErr != nil { - return fmt.Errorf("failed to close ingest file: %w", err) + return fmt.Errorf("failed to close ingest file: %w", closeErr) } if size > 0 && size != fi.Size() {