Description
Some errors could use cleaning up; they're wrapped multiple times, now having both a (e.g.) NotFound: prefix and a not found suffix;
$ docker load --platform linux/s390x -i alpine2.tar
requested platform (linux/s390x) found, but some content is missing: NotFound: content digest sha256:2b5b26e09ca2856f50ac88312348d26c1ac4b8af1df9f580e5cf465fd76e3d4d: not found
$ docker image ls --tree
IMAGE ID DISK USAGE CONTENT SIZE IN USE
$ docker load -i alpine2.tar
Loaded image: alpine:latest
docker image ls --tree
IMAGE ID DISK USAGE CONTENT SIZE IN USE
alpine:latest beefdbd8a1da 16.9MB 7.46MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 3.37MB 3.37MB
└─ linux/s390x 2b5b26e09ca2 0B 0B
The error message is a bit ugly with the NotFound: prefix, and the (somewhat) obscure "content digest ...";
NotFound: content digest sha256:2b5b26e09ca2856f50ac88312348d26c1ac4b8af1df9f580e5cf465fd76e3d4d: not found
I was hoping perhaps some trick like unwrapping it would work to clean it up, but that's stripping exactly the wrong parts, and only preserves the not found;
docker load --platform linux/s390x -i alpine2.tar
requested platform (linux/s390x) found, but some content is missing: not found
It looks like these NotFound: prefixes are from gRPC;
|
case NotFound: |
|
return "NotFound" |
I tried using status.FromError() on them to get the error-message, but that didn't work; it looks like containerd's errdefs package has a rebaseMessage function to do something similar and to cleanup the error, but it's either not called in our call-path, or perhaps something wrapped the error and it's discarded;
|
func rebaseMessage(cls error, err error) string { |
|
desc := errDesc(err) |
|
clss := cls.Error() |
|
if desc == clss { |
|
return "" |
|
} |
|
|
|
return strings.TrimSuffix(desc, ": "+clss) |
|
} |
|
|
|
func isGRPCError(err error) bool { |
|
_, ok := status.FromError(err) |
|
return ok |
|
} |
|
|
|
func code(err error) codes.Code { |
|
if s, ok := status.FromError(err); ok { |
|
return s.Code() |
|
} |
|
return codes.Unknown |
|
} |
|
|
|
func errDesc(err error) string { |
|
if s, ok := status.FromError(err); ok { |
|
return s.Message() |
|
} |
|
return err.Error() |
|
} |
Description
Some errors could use cleaning up; they're wrapped multiple times, now having both a (e.g.)
NotFound:prefix and anot foundsuffix;The error message is a bit ugly with the
NotFound:prefix, and the (somewhat) obscure "content digest ...";NotFound: content digest sha256:2b5b26e09ca2856f50ac88312348d26c1ac4b8af1df9f580e5cf465fd76e3d4d: not foundI was hoping perhaps some trick like unwrapping it would work to clean it up, but that's stripping exactly the wrong parts, and only preserves the
not found;It looks like these
NotFound:prefixes are from gRPC;moby/vendor/google.golang.org/grpc/codes/code_string.go
Lines 43 to 44 in 1240301
I tried using
status.FromError()on them to get the error-message, but that didn't work; it looks like containerd's errdefs package has arebaseMessagefunction to do something similar and to cleanup the error, but it's either not called in our call-path, or perhaps something wrapped the error and it's discarded;moby/vendor/github.com/containerd/errdefs/grpc.go
Lines 120 to 147 in 1240301