diff --git a/cache/compression_nydus.go b/cache/compression_nydus.go index 2f5f10bd1..48b61a4b3 100644 --- a/cache/compression_nydus.go +++ b/cache/compression_nydus.go @@ -7,7 +7,6 @@ import ( "compress/gzip" "context" "encoding/json" - "fmt" "io" "github.com/containerd/containerd/content" @@ -50,11 +49,11 @@ func needsForceCompression(ctx context.Context, cs content.Store, source ocispec func MergeNydus(ctx context.Context, ref ImmutableRef, comp compression.Config, s session.Group) (*ocispecs.Descriptor, error) { iref, ok := ref.(*immutableRef) if !ok { - return nil, fmt.Errorf("unsupported ref") + return nil, errors.Errorf("unsupported ref type %T", ref) } refs := iref.layerChain() if len(refs) == 0 { - return nil, fmt.Errorf("refs can't be empty") + return nil, errors.Errorf("refs can't be empty") } // Extracts nydus bootstrap from nydus format for each layer. diff --git a/cache/manager_test.go b/cache/manager_test.go index e7677cb0f..cd58a4042 100644 --- a/cache/manager_test.go +++ b/cache/manager_test.go @@ -1454,7 +1454,7 @@ func ensurePrune(ctx context.Context, t *testing.T, cm Manager, pruneNum, maxRet func getCompressor(w io.Writer, compressionType compression.Type, customized bool) (io.WriteCloser, error) { switch compressionType { case compression.Uncompressed: - return nil, fmt.Errorf("compression is not requested: %v", compressionType) + return nil, errors.Errorf("compression is not requested: %v", compressionType) case compression.Gzip: if customized { gz, _ := gzip.NewWriterLevel(w, gzip.NoCompression) @@ -1495,7 +1495,7 @@ func getCompressor(w io.Writer, compressionType compression.Type, customized boo } return zstd.NewWriter(w) default: - return nil, fmt.Errorf("unknown compression type: %q", compressionType) + return nil, errors.Errorf("unknown compression type: %q", compressionType) } } diff --git a/cache/refs.go b/cache/refs.go index 2bb0ba115..cb039779a 100644 --- a/cache/refs.go +++ b/cache/refs.go @@ -836,11 +836,11 @@ func getBlobDesc(ctx context.Context, cs content.Store, dgst digest.Digest) (oci return ocispecs.Descriptor{}, err } if info.Labels == nil { - return ocispecs.Descriptor{}, fmt.Errorf("no blob metadata is stored for %q", info.Digest) + return ocispecs.Descriptor{}, errors.Errorf("no blob metadata is stored for %q", info.Digest) } mt, ok := info.Labels[blobMediaTypeLabel] if !ok { - return ocispecs.Descriptor{}, fmt.Errorf("no media type is stored for %q", info.Digest) + return ocispecs.Descriptor{}, errors.Errorf("no media type is stored for %q", info.Digest) } desc := ocispecs.Descriptor{ Digest: info.Digest, @@ -1550,12 +1550,12 @@ func readonlyOverlay(opt []string) []string { func newSharableMountPool(tmpdirRoot string) (sharableMountPool, error) { if tmpdirRoot != "" { if err := os.MkdirAll(tmpdirRoot, 0700); err != nil { - return sharableMountPool{}, fmt.Errorf("failed to prepare mount pool: %w", err) + return sharableMountPool{}, errors.Wrap(err, "failed to prepare mount pool") } // If tmpdirRoot is specified, remove existing mounts to avoid conflict. files, err := os.ReadDir(tmpdirRoot) if err != nil { - return sharableMountPool{}, fmt.Errorf("failed to read mount pool: %w", err) + return sharableMountPool{}, errors.Wrap(err, "failed to read mount pool") } for _, file := range files { if file.IsDir() {