Merge pull request #6414 from dmcgowan/followup-errors-change

Followup errors change
This commit is contained in:
Derek McGowan 2022-01-08 10:07:34 -08:00 committed by GitHub
commit ee326447e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 3 deletions

View File

@ -212,6 +212,9 @@ func seekReader(r io.Reader, offset, size int64) (io.Reader, error) {
if ok { if ok {
nn, err := seeker.Seek(offset, io.SeekStart) nn, err := seeker.Seek(offset, io.SeekStart)
if nn != offset { 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) return nil, fmt.Errorf("failed to seek to offset %v: %w", offset, err)
} }

View File

@ -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) return fmt.Errorf("stat on ingest file failed: %w", err)
} }
if closeErr != nil { 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() { if size > 0 && size != fi.Size() {

View File

@ -32,7 +32,7 @@ var tempMountLocation = getTempDir()
func WithTempMount(ctx context.Context, mounts []Mount, f func(root string) error) (err error) { func WithTempMount(ctx context.Context, mounts []Mount, f func(root string) error) (err error) {
root, uerr := os.MkdirTemp(tempMountLocation, "containerd-mount") root, uerr := os.MkdirTemp(tempMountLocation, "containerd-mount")
if uerr != nil { 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. // We use Remove here instead of RemoveAll.
// The RemoveAll will delete the temp dir and all children it contains. // The RemoveAll will delete the temp dir and all children it contains.

View File

@ -244,7 +244,7 @@ func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, st
if (manifestStack[i].MediaType == ocispec.MediaTypeImageIndex || if (manifestStack[i].MediaType == ocispec.MediaTypeImageIndex ||
manifestStack[i].MediaType == images.MediaTypeDockerSchema2ManifestList) && manifestStack[i].MediaType == images.MediaTypeDockerSchema2ManifestList) &&
errors.Unwrap(err) != nil && strings.Contains(errors.Unwrap(err).Error(), "400 Bad Request") { 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 return err
} }