Skip to content

Commit f67de00

Browse files
committed
archive: add human-readable hint to Lchown error
Before: ``` $ nerdctl pull gcr.io/kubeflow-images-public/tensorflow-1.14.0-notebook-cpu:v0.7.0 FATA[0026] failed to extract layer sha256:f8a604834d388fd3d04c26e4ed832b36b617ea8a4e0b1665b9199bd10cfcb171: mount callback failed on /var/lib/containerd/tmpmounts/containerd-mount1818823128: lchown /var/lib/containerd/tmpmounts/containerd-mount1818823128/usr/local/bin/docker-credential-gcr: invalid argument: unknown ``` After: ``` $ nerdctl pull gcr.io/kubeflow-images-public/tensorflow-1.14.0-notebook-cpu:v0.7.0 FATA[0027] failed to extract layer sha256:f8a604834d388fd3d04c26e4ed832b36b617ea8a4e0b1665b9199bd10cfcb171: mount callback failed on /var/lib/containerd/tmpmounts/containerd-mount3521205359: failed to Lchown "/var/lib/containerd/tmpmounts/containerd-mount3521205359/usr/local/bin/docker-credential-gcr" for UID 205001, GID 5000: lchown /var/lib/containerd/tmpmounts/containerd-mount3521205359/usr/local/bin/docker-credential-gcr: invalid argument (Hint: try increasing the number of subordinate IDs in /etc/subuid and /etc/subgid): unknown ``` Related to moby/moby issue 43576 but for containerd Signed-off-by: Akihiro Suda <[email protected]> (cherry picked from commit d2f3015) Signed-off-by: Akihiro Suda <[email protected]>
1 parent 6501621 commit f67de00

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

archive/tar.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package archive
1919
import (
2020
"archive/tar"
2121
"context"
22+
"fmt"
2223
"io"
2324
"os"
2425
"path/filepath"
@@ -29,6 +30,7 @@ import (
2930
"time"
3031

3132
"github.com/containerd/containerd/log"
33+
"github.com/containerd/containerd/pkg/userns"
3234
"github.com/containerd/continuity/fs"
3335
"github.com/pkg/errors"
3436
)
@@ -376,6 +378,10 @@ func createTarFile(ctx context.Context, path, extractDir string, hdr *tar.Header
376378
// Lchown is not supported on Windows.
377379
if runtime.GOOS != "windows" {
378380
if err := os.Lchown(path, hdr.Uid, hdr.Gid); err != nil {
381+
err = fmt.Errorf("failed to Lchown %q for UID %d, GID %d: %w", path, hdr.Uid, hdr.Gid, err)
382+
if errors.Is(err, syscall.EINVAL) && userns.RunningInUserNS() {
383+
err = fmt.Errorf("%w (Hint: try increasing the number of subordinate IDs in /etc/subuid and /etc/subgid)", err)
384+
}
379385
return err
380386
}
381387
}

0 commit comments

Comments
 (0)