From 02661c70a441ce5839fe33cf4647b1aff526bd7a Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Mon, 4 Dec 2017 17:54:08 -0500 Subject: [PATCH] Add more descriptive error on manifest list push Adds a more descriptive error message for pushing indexes/manifest list references with missing content references to a docker v2 API supporting container registry. This can be followed up with a more complete review of how to handle "deep" references for manifest lists on push/pull post containerd 1.0. Signed-off-by: Phil Estes --- client.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client.go b/client.go index 5c20335ea..3c417aa3f 100644 --- a/client.go +++ b/client.go @@ -7,6 +7,7 @@ import ( "net/http" "runtime" "strconv" + "strings" "sync" "time" @@ -334,6 +335,14 @@ func (c *Client) Push(ctx context.Context, ref string, desc ocispec.Descriptor, for i := len(manifestStack) - 1; i >= 0; i-- { _, err := pushHandler(ctx, manifestStack[i]) if err != nil { + // TODO(estesp): until we have a more complete method for index push, we need to report + // missing dependencies in an index/manifest list by sensing the "400 Bad Request" + // as a marker for this problem + if (manifestStack[i].MediaType == ocispec.MediaTypeImageIndex || + manifestStack[i].MediaType == images.MediaTypeDockerSchema2ManifestList) && + errors.Cause(err) != nil && strings.Contains(errors.Cause(err).Error(), "400 Bad Request") { + return errors.Wrap(err, "manifest list/index references to blobs and/or manifests are missing in your target registry") + } return err } }