Update vendored distribution repo to new version

This version includes a fix that avoids checking against specific HTTP
status codes. The previous behavior violated the registry API spec.

Fixes #14975

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
(cherry picked from commit 091dbc1034)
This commit is contained in:
Aaron Lehmann 2015-07-27 09:37:38 -07:00 committed by David Calavera
parent 36b6e5884d
commit fa85dc0030
11 changed files with 199 additions and 59 deletions

View file

@ -35,7 +35,7 @@ clone git github.com/coreos/go-etcd v2.0.0
clone git github.com/hashicorp/consul v0.5.2 clone git github.com/hashicorp/consul v0.5.2
# get graph and distribution packages # get graph and distribution packages
clone git github.com/docker/distribution cd8ff553b6b1911be23dfeabb73e33108bcbf147 clone git github.com/docker/distribution e83345626608aa943d5c8a027fddcf54814d9545
clone git github.com/vbatts/tar-split v0.9.4 clone git github.com/vbatts/tar-split v0.9.4
clone git github.com/docker/notary 77bced079e83d80f40c1f0a544b1a8a3b97fb052 clone git github.com/docker/notary 77bced079e83d80f40c1f0a544b1a8a3b97fb052

View file

@ -27,6 +27,9 @@ var (
// ErrBlobInvalidLength returned when the blob has an expected length on // ErrBlobInvalidLength returned when the blob has an expected length on
// commit, meaning mismatched with the descriptor or an invalid value. // commit, meaning mismatched with the descriptor or an invalid value.
ErrBlobInvalidLength = errors.New("blob invalid length") ErrBlobInvalidLength = errors.New("blob invalid length")
// ErrUnsupported returned when an unsupported operation is attempted
ErrUnsupported = errors.New("unsupported operation")
) )
// ErrBlobInvalidDigest returned when digest check fails. // ErrBlobInvalidDigest returned when digest check fails.
@ -70,6 +73,11 @@ type BlobStatter interface {
Stat(ctx context.Context, dgst digest.Digest) (Descriptor, error) Stat(ctx context.Context, dgst digest.Digest) (Descriptor, error)
} }
// BlobDeleter enables deleting blobs from storage.
type BlobDeleter interface {
Delete(ctx context.Context, dgst digest.Digest) error
}
// BlobDescriptorService manages metadata about a blob by digest. Most // BlobDescriptorService manages metadata about a blob by digest. Most
// implementations will not expose such an interface explicitly. Such mappings // implementations will not expose such an interface explicitly. Such mappings
// should be maintained by interacting with the BlobIngester. Hence, this is // should be maintained by interacting with the BlobIngester. Hence, this is
@ -87,6 +95,9 @@ type BlobDescriptorService interface {
// the restriction that the algorithm of the descriptor must match the // the restriction that the algorithm of the descriptor must match the
// canonical algorithm (ie sha256) of the annotator. // canonical algorithm (ie sha256) of the annotator.
SetDescriptor(ctx context.Context, dgst digest.Digest, desc Descriptor) error SetDescriptor(ctx context.Context, dgst digest.Digest, desc Descriptor) error
// Clear enables descriptors to be unlinked
Clear(ctx context.Context, dgst digest.Digest) error
} }
// ReadSeekCloser is the primary reader type for blob data, combining // ReadSeekCloser is the primary reader type for blob data, combining
@ -183,8 +194,9 @@ type BlobService interface {
} }
// BlobStore represent the entire suite of blob related operations. Such an // BlobStore represent the entire suite of blob related operations. Such an
// implementation can access, read, write and serve blobs. // implementation can access, read, write, delete and serve blobs.
type BlobStore interface { type BlobStore interface {
BlobService BlobService
BlobServer BlobServer
BlobDeleter
} }

View file

@ -398,6 +398,8 @@ var routeDescriptors = []RouteDescriptor{
Description: "Fetch the tags under the repository identified by `name`.", Description: "Fetch the tags under the repository identified by `name`.",
Requests: []RequestDescriptor{ Requests: []RequestDescriptor{
{ {
Name: "Tags",
Description: "Return all tags for the repository",
Headers: []ParameterDescriptor{ Headers: []ParameterDescriptor{
hostHeader, hostHeader,
authHeader, authHeader,
@ -455,6 +457,7 @@ var routeDescriptors = []RouteDescriptor{
}, },
}, },
{ {
Name: "Tags Paginated",
Description: "Return a portion of the tags for the specified repository.", Description: "Return a portion of the tags for the specified repository.",
PathParameters: []ParameterDescriptor{nameParameterDescriptor}, PathParameters: []ParameterDescriptor{nameParameterDescriptor},
QueryParameters: paginationParameters, QueryParameters: paginationParameters,
@ -483,6 +486,30 @@ var routeDescriptors = []RouteDescriptor{
}, },
}, },
}, },
Failures: []ResponseDescriptor{
{
StatusCode: http.StatusNotFound,
Description: "The repository is not known to the registry.",
Body: BodyDescriptor{
ContentType: "application/json; charset=utf-8",
Format: errorsBody,
},
ErrorCodes: []errcode.ErrorCode{
ErrorCodeNameUnknown,
},
},
{
StatusCode: http.StatusUnauthorized,
Description: "The client does not have access to the repository.",
Body: BodyDescriptor{
ContentType: "application/json; charset=utf-8",
Format: errorsBody,
},
ErrorCodes: []errcode.ErrorCode{
ErrorCodeUnauthorized,
},
},
},
}, },
}, },
}, },

View file

@ -10,6 +10,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/docker/distribution/registry/client"
"github.com/docker/distribution/registry/client/transport" "github.com/docker/distribution/registry/client/transport"
) )
@ -209,7 +210,7 @@ func (th *tokenHandler) fetchToken(params map[string]string) (token string, err
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if !client.SuccessStatus(resp.StatusCode) {
return "", fmt.Errorf("token auth attempt for registry: %s request failed with status: %d %s", req.URL, resp.StatusCode, http.StatusText(resp.StatusCode)) return "", fmt.Errorf("token auth attempt for registry: %s request failed with status: %d %s", req.URL, resp.StatusCode, http.StatusText(resp.StatusCode))
} }

View file

@ -44,7 +44,7 @@ func (hbu *httpBlobUpload) ReadFrom(r io.Reader) (n int64, err error) {
return 0, err return 0, err
} }
if resp.StatusCode != http.StatusAccepted { if !SuccessStatus(resp.StatusCode) {
return 0, hbu.handleErrorResponse(resp) return 0, hbu.handleErrorResponse(resp)
} }
@ -79,7 +79,7 @@ func (hbu *httpBlobUpload) Write(p []byte) (n int, err error) {
return 0, err return 0, err
} }
if resp.StatusCode != http.StatusAccepted { if !SuccessStatus(resp.StatusCode) {
return 0, hbu.handleErrorResponse(resp) return 0, hbu.handleErrorResponse(resp)
} }
@ -142,7 +142,7 @@ func (hbu *httpBlobUpload) Commit(ctx context.Context, desc distribution.Descrip
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusCreated { if !SuccessStatus(resp.StatusCode) {
return distribution.Descriptor{}, hbu.handleErrorResponse(resp) return distribution.Descriptor{}, hbu.handleErrorResponse(resp)
} }
@ -160,12 +160,10 @@ func (hbu *httpBlobUpload) Cancel(ctx context.Context) error {
} }
defer resp.Body.Close() defer resp.Body.Close()
switch resp.StatusCode { if resp.StatusCode == http.StatusNotFound || SuccessStatus(resp.StatusCode) {
case http.StatusNoContent, http.StatusNotFound:
return nil return nil
default:
return hbu.handleErrorResponse(resp)
} }
return hbu.handleErrorResponse(resp)
} }
func (hbu *httpBlobUpload) Close() error { func (hbu *httpBlobUpload) Close() error {

View file

@ -61,3 +61,9 @@ func handleErrorResponse(resp *http.Response) error {
} }
return &UnexpectedHTTPStatusError{Status: resp.Status} return &UnexpectedHTTPStatusError{Status: resp.Status}
} }
// SuccessStatus returns true if the argument is a successful HTTP response
// code (in the range 200 - 399 inclusive).
func SuccessStatus(status int) bool {
return status >= 200 && status <= 399
}

View file

@ -70,8 +70,7 @@ func (r *registry) Repositories(ctx context.Context, entries []string, last stri
} }
defer resp.Body.Close() defer resp.Body.Close()
switch resp.StatusCode { if SuccessStatus(resp.StatusCode) {
case http.StatusOK:
var ctlg struct { var ctlg struct {
Repositories []string `json:"repositories"` Repositories []string `json:"repositories"`
} }
@ -90,8 +89,7 @@ func (r *registry) Repositories(ctx context.Context, entries []string, last stri
if link == "" { if link == "" {
returnErr = io.EOF returnErr = io.EOF
} }
} else {
default:
return 0, handleErrorResponse(resp) return 0, handleErrorResponse(resp)
} }
@ -199,8 +197,7 @@ func (ms *manifests) Tags() ([]string, error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
switch resp.StatusCode { if SuccessStatus(resp.StatusCode) {
case http.StatusOK:
b, err := ioutil.ReadAll(resp.Body) b, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
@ -214,11 +211,10 @@ func (ms *manifests) Tags() ([]string, error) {
} }
return tagsResponse.Tags, nil return tagsResponse.Tags, nil
case http.StatusNotFound: } else if resp.StatusCode == http.StatusNotFound {
return nil, nil return nil, nil
default:
return nil, handleErrorResponse(resp)
} }
return nil, handleErrorResponse(resp)
} }
func (ms *manifests) Exists(dgst digest.Digest) (bool, error) { func (ms *manifests) Exists(dgst digest.Digest) (bool, error) {
@ -238,14 +234,12 @@ func (ms *manifests) ExistsByTag(tag string) (bool, error) {
return false, err return false, err
} }
switch resp.StatusCode { if SuccessStatus(resp.StatusCode) {
case http.StatusOK:
return true, nil return true, nil
case http.StatusNotFound: } else if resp.StatusCode == http.StatusNotFound {
return false, nil return false, nil
default:
return false, handleErrorResponse(resp)
} }
return false, handleErrorResponse(resp)
} }
func (ms *manifests) Get(dgst digest.Digest) (*manifest.SignedManifest, error) { func (ms *manifests) Get(dgst digest.Digest) (*manifest.SignedManifest, error) {
@ -254,13 +248,14 @@ func (ms *manifests) Get(dgst digest.Digest) (*manifest.SignedManifest, error) {
return ms.GetByTag(dgst.String()) return ms.GetByTag(dgst.String())
} }
// AddEtagToTag allows a client to supply an eTag to GetByTag which will // AddEtagToTag allows a client to supply an eTag to GetByTag which will be
// be used for a conditional HTTP request. If the eTag matches, a nil // used for a conditional HTTP request. If the eTag matches, a nil manifest
// manifest and nil error will be returned. // and nil error will be returned. etag is automatically quoted when added to
func AddEtagToTag(tagName, dgst string) distribution.ManifestServiceOption { // this map.
func AddEtagToTag(tag, etag string) distribution.ManifestServiceOption {
return func(ms distribution.ManifestService) error { return func(ms distribution.ManifestService) error {
if ms, ok := ms.(*manifests); ok { if ms, ok := ms.(*manifests); ok {
ms.etags[tagName] = dgst ms.etags[tag] = fmt.Sprintf(`"%s"`, etag)
return nil return nil
} }
return fmt.Errorf("etag options is a client-only option") return fmt.Errorf("etag options is a client-only option")
@ -293,8 +288,9 @@ func (ms *manifests) GetByTag(tag string, options ...distribution.ManifestServic
} }
defer resp.Body.Close() defer resp.Body.Close()
switch resp.StatusCode { if resp.StatusCode == http.StatusNotModified {
case http.StatusOK: return nil, nil
} else if SuccessStatus(resp.StatusCode) {
var sm manifest.SignedManifest var sm manifest.SignedManifest
decoder := json.NewDecoder(resp.Body) decoder := json.NewDecoder(resp.Body)
@ -302,11 +298,8 @@ func (ms *manifests) GetByTag(tag string, options ...distribution.ManifestServic
return nil, err return nil, err
} }
return &sm, nil return &sm, nil
case http.StatusNotModified:
return nil, nil
default:
return nil, handleErrorResponse(resp)
} }
return nil, handleErrorResponse(resp)
} }
func (ms *manifests) Put(m *manifest.SignedManifest) error { func (ms *manifests) Put(m *manifest.SignedManifest) error {
@ -328,13 +321,11 @@ func (ms *manifests) Put(m *manifest.SignedManifest) error {
} }
defer resp.Body.Close() defer resp.Body.Close()
switch resp.StatusCode { if SuccessStatus(resp.StatusCode) {
case http.StatusAccepted:
// TODO(dmcgowan): make use of digest header // TODO(dmcgowan): make use of digest header
return nil return nil
default:
return handleErrorResponse(resp)
} }
return handleErrorResponse(resp)
} }
func (ms *manifests) Delete(dgst digest.Digest) error { func (ms *manifests) Delete(dgst digest.Digest) error {
@ -353,12 +344,10 @@ func (ms *manifests) Delete(dgst digest.Digest) error {
} }
defer resp.Body.Close() defer resp.Body.Close()
switch resp.StatusCode { if SuccessStatus(resp.StatusCode) {
case http.StatusOK:
return nil return nil
default:
return handleErrorResponse(resp)
} }
return handleErrorResponse(resp)
} }
type blobs struct { type blobs struct {
@ -366,7 +355,8 @@ type blobs struct {
ub *v2.URLBuilder ub *v2.URLBuilder
client *http.Client client *http.Client
statter distribution.BlobStatter statter distribution.BlobDescriptorService
distribution.BlobDeleter
} }
func sanitizeLocation(location, source string) (string, error) { func sanitizeLocation(location, source string) (string, error) {
@ -459,8 +449,7 @@ func (bs *blobs) Create(ctx context.Context) (distribution.BlobWriter, error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
switch resp.StatusCode { if SuccessStatus(resp.StatusCode) {
case http.StatusAccepted:
// TODO(dmcgowan): Check for invalid UUID // TODO(dmcgowan): Check for invalid UUID
uuid := resp.Header.Get("Docker-Upload-UUID") uuid := resp.Header.Get("Docker-Upload-UUID")
location, err := sanitizeLocation(resp.Header.Get("Location"), u) location, err := sanitizeLocation(resp.Header.Get("Location"), u)
@ -475,15 +464,18 @@ func (bs *blobs) Create(ctx context.Context) (distribution.BlobWriter, error) {
startedAt: time.Now(), startedAt: time.Now(),
location: location, location: location,
}, nil }, nil
default:
return nil, handleErrorResponse(resp)
} }
return nil, handleErrorResponse(resp)
} }
func (bs *blobs) Resume(ctx context.Context, id string) (distribution.BlobWriter, error) { func (bs *blobs) Resume(ctx context.Context, id string) (distribution.BlobWriter, error) {
panic("not implemented") panic("not implemented")
} }
func (bs *blobs) Delete(ctx context.Context, dgst digest.Digest) error {
return bs.statter.Clear(ctx, dgst)
}
type blobStatter struct { type blobStatter struct {
name string name string
ub *v2.URLBuilder ub *v2.URLBuilder
@ -502,8 +494,7 @@ func (bs *blobStatter) Stat(ctx context.Context, dgst digest.Digest) (distributi
} }
defer resp.Body.Close() defer resp.Body.Close()
switch resp.StatusCode { if SuccessStatus(resp.StatusCode) {
case http.StatusOK:
lengthHeader := resp.Header.Get("Content-Length") lengthHeader := resp.Header.Get("Content-Length")
length, err := strconv.ParseInt(lengthHeader, 10, 64) length, err := strconv.ParseInt(lengthHeader, 10, 64)
if err != nil { if err != nil {
@ -515,11 +506,10 @@ func (bs *blobStatter) Stat(ctx context.Context, dgst digest.Digest) (distributi
Size: length, Size: length,
Digest: dgst, Digest: dgst,
}, nil }, nil
case http.StatusNotFound: } else if resp.StatusCode == http.StatusNotFound {
return distribution.Descriptor{}, distribution.ErrBlobUnknown return distribution.Descriptor{}, distribution.ErrBlobUnknown
default:
return distribution.Descriptor{}, handleErrorResponse(resp)
} }
return distribution.Descriptor{}, handleErrorResponse(resp)
} }
func buildCatalogValues(maxEntries int, last string) url.Values { func buildCatalogValues(maxEntries int, last string) url.Values {
@ -535,3 +525,30 @@ func buildCatalogValues(maxEntries int, last string) url.Values {
return values return values
} }
func (bs *blobStatter) Clear(ctx context.Context, dgst digest.Digest) error {
blobURL, err := bs.ub.BuildBlobURL(bs.name, dgst)
if err != nil {
return err
}
req, err := http.NewRequest("DELETE", blobURL, nil)
if err != nil {
return err
}
resp, err := bs.client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if SuccessStatus(resp.StatusCode) {
return nil
}
return handleErrorResponse(resp)
}
func (bs *blobStatter) SetDescriptor(ctx context.Context, dgst digest.Digest, desc distribution.Descriptor) error {
return nil
}

View file

@ -154,10 +154,11 @@ func (hrs *httpReadSeeker) reader() (io.Reader, error) {
return nil, err return nil, err
} }
switch { // Normally would use client.SuccessStatus, but that would be a cyclic
case resp.StatusCode == 200: // import
if resp.StatusCode >= 200 && resp.StatusCode <= 399 {
hrs.rc = resp.Body hrs.rc = resp.Body
default: } else {
defer resp.Body.Close() defer resp.Body.Close()
return nil, fmt.Errorf("unexpected status resolving reader: %v", resp.Status) return nil, fmt.Errorf("unexpected status resolving reader: %v", resp.Status)
} }

View file

@ -26,13 +26,13 @@ type MetricsTracker interface {
type cachedBlobStatter struct { type cachedBlobStatter struct {
cache distribution.BlobDescriptorService cache distribution.BlobDescriptorService
backend distribution.BlobStatter backend distribution.BlobDescriptorService
tracker MetricsTracker tracker MetricsTracker
} }
// NewCachedBlobStatter creates a new statter which prefers a cache and // NewCachedBlobStatter creates a new statter which prefers a cache and
// falls back to a backend. // falls back to a backend.
func NewCachedBlobStatter(cache distribution.BlobDescriptorService, backend distribution.BlobStatter) distribution.BlobStatter { func NewCachedBlobStatter(cache distribution.BlobDescriptorService, backend distribution.BlobDescriptorService) distribution.BlobDescriptorService {
return &cachedBlobStatter{ return &cachedBlobStatter{
cache: cache, cache: cache,
backend: backend, backend: backend,
@ -41,7 +41,7 @@ func NewCachedBlobStatter(cache distribution.BlobDescriptorService, backend dist
// NewCachedBlobStatterWithMetrics creates a new statter which prefers a cache and // NewCachedBlobStatterWithMetrics creates a new statter which prefers a cache and
// falls back to a backend. Hits and misses will send to the tracker. // falls back to a backend. Hits and misses will send to the tracker.
func NewCachedBlobStatterWithMetrics(cache distribution.BlobDescriptorService, backend distribution.BlobStatter, tracker MetricsTracker) distribution.BlobStatter { func NewCachedBlobStatterWithMetrics(cache distribution.BlobDescriptorService, backend distribution.BlobDescriptorService, tracker MetricsTracker) distribution.BlobStatter {
return &cachedBlobStatter{ return &cachedBlobStatter{
cache: cache, cache: cache,
backend: backend, backend: backend,
@ -77,4 +77,25 @@ fallback:
} }
return desc, err return desc, err
}
func (cbds *cachedBlobStatter) Clear(ctx context.Context, dgst digest.Digest) error {
err := cbds.cache.Clear(ctx, dgst)
if err != nil {
return err
}
err = cbds.backend.Clear(ctx, dgst)
if err != nil {
return err
}
return nil
}
func (cbds *cachedBlobStatter) SetDescriptor(ctx context.Context, dgst digest.Digest, desc distribution.Descriptor) error {
if err := cbds.cache.SetDescriptor(ctx, dgst, desc); err != nil {
context.GetLogger(ctx).Errorf("error adding descriptor %v to cache: %v", desc.Digest, err)
}
return nil
} }

View file

@ -44,6 +44,10 @@ func (imbdcp *inMemoryBlobDescriptorCacheProvider) Stat(ctx context.Context, dgs
return imbdcp.global.Stat(ctx, dgst) return imbdcp.global.Stat(ctx, dgst)
} }
func (imbdcp *inMemoryBlobDescriptorCacheProvider) Clear(ctx context.Context, dgst digest.Digest) error {
return imbdcp.global.Clear(ctx, dgst)
}
func (imbdcp *inMemoryBlobDescriptorCacheProvider) SetDescriptor(ctx context.Context, dgst digest.Digest, desc distribution.Descriptor) error { func (imbdcp *inMemoryBlobDescriptorCacheProvider) SetDescriptor(ctx context.Context, dgst digest.Digest, desc distribution.Descriptor) error {
_, err := imbdcp.Stat(ctx, dgst) _, err := imbdcp.Stat(ctx, dgst)
if err == distribution.ErrBlobUnknown { if err == distribution.ErrBlobUnknown {
@ -80,6 +84,14 @@ func (rsimbdcp *repositoryScopedInMemoryBlobDescriptorCache) Stat(ctx context.Co
return rsimbdcp.repository.Stat(ctx, dgst) return rsimbdcp.repository.Stat(ctx, dgst)
} }
func (rsimbdcp *repositoryScopedInMemoryBlobDescriptorCache) Clear(ctx context.Context, dgst digest.Digest) error {
if rsimbdcp.repository == nil {
return distribution.ErrBlobUnknown
}
return rsimbdcp.repository.Clear(ctx, dgst)
}
func (rsimbdcp *repositoryScopedInMemoryBlobDescriptorCache) SetDescriptor(ctx context.Context, dgst digest.Digest, desc distribution.Descriptor) error { func (rsimbdcp *repositoryScopedInMemoryBlobDescriptorCache) SetDescriptor(ctx context.Context, dgst digest.Digest, desc distribution.Descriptor) error {
if rsimbdcp.repository == nil { if rsimbdcp.repository == nil {
// allocate map since we are setting it now. // allocate map since we are setting it now.
@ -133,6 +145,14 @@ func (mbdc *mapBlobDescriptorCache) Stat(ctx context.Context, dgst digest.Digest
return desc, nil return desc, nil
} }
func (mbdc *mapBlobDescriptorCache) Clear(ctx context.Context, dgst digest.Digest) error {
mbdc.mu.Lock()
defer mbdc.mu.Unlock()
delete(mbdc.descriptors, dgst)
return nil
}
func (mbdc *mapBlobDescriptorCache) SetDescriptor(ctx context.Context, dgst digest.Digest, desc distribution.Descriptor) error { func (mbdc *mapBlobDescriptorCache) SetDescriptor(ctx context.Context, dgst digest.Digest, desc distribution.Descriptor) error {
if err := dgst.Validate(); err != nil { if err := dgst.Validate(); err != nil {
return err return err

View file

@ -139,3 +139,40 @@ func checkBlobDescriptorCacheSetAndRead(t *testing.T, ctx context.Context, provi
t.Fatalf("unexpected descriptor: %#v != %#v", desc, expected) t.Fatalf("unexpected descriptor: %#v != %#v", desc, expected)
} }
} }
func checkBlobDescriptorClear(t *testing.T, ctx context.Context, provider BlobDescriptorCacheProvider) {
localDigest := digest.Digest("sha384:abc")
expected := distribution.Descriptor{
Digest: "sha256:abc",
Size: 10,
MediaType: "application/octet-stream"}
cache, err := provider.RepositoryScoped("foo/bar")
if err != nil {
t.Fatalf("unexpected error getting scoped cache: %v", err)
}
if err := cache.SetDescriptor(ctx, localDigest, expected); err != nil {
t.Fatalf("error setting descriptor: %v", err)
}
desc, err := cache.Stat(ctx, localDigest)
if err != nil {
t.Fatalf("unexpected error statting fake2:abc: %v", err)
}
if expected != desc {
t.Fatalf("unexpected descriptor: %#v != %#v", expected, desc)
}
err = cache.Clear(ctx, localDigest)
if err != nil {
t.Fatalf("unexpected error deleting descriptor")
}
nonExistantDigest := digest.Digest("sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
err = cache.Clear(ctx, nonExistantDigest)
if err == nil {
t.Fatalf("expected error deleting unknown descriptor")
}
}