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 <estesp@linux.vnet.ibm.com>
This commit is contained in:
Phil Estes 2017-12-04 17:54:08 -05:00
parent cc969fb42f
commit 02661c70a4
No known key found for this signature in database
GPG Key ID: 0F386284C03A1162

View File

@ -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
}
}