Skip to content

Commit

Permalink
Don't require a Docker-Content-Digest header when deleting images
Browse files Browse the repository at this point in the history
Per #1010 , it seems
the header is not populated by AWS ECR.

We were actually computing the digest from the manifest bytes
already, so this is both more robust and simpler.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Apr 14, 2022
1 parent d2d961d commit 377c319
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions docker/docker_image_src.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,11 @@ func deleteImage(ctx context.Context, sys *types.SystemContext, ref dockerRefere
return errors.Errorf("Failed to delete %v: %s (%v)", ref.ref, manifestBody, get.Status)
}

digest := get.Header.Get("Docker-Content-Digest")
deletePath := fmt.Sprintf(manifestPath, reference.Path(ref.ref), digest)
manifestDigest, err := manifest.Digest(manifestBody)
if err != nil {
return fmt.Errorf("computing manifest digest: %w", err)
}
deletePath := fmt.Sprintf(manifestPath, reference.Path(ref.ref), manifestDigest)

// When retrieving the digest from a registry >= 2.3 use the following header:
// "Accept": "application/vnd.docker.distribution.manifest.v2+json"
Expand All @@ -629,11 +632,6 @@ func deleteImage(ctx context.Context, sys *types.SystemContext, ref dockerRefere
return errors.Errorf("Failed to delete %v: %s (%v)", deletePath, string(body), delete.Status)
}

manifestDigest, err := manifest.Digest(manifestBody)
if err != nil {
return err
}

for i := 0; ; i++ {
url := signatureStorageURL(c.signatureBase, manifestDigest, i)
missing, err := c.deleteOneSignature(url)
Expand Down

0 comments on commit 377c319

Please sign in to comment.