Skip to content

Commit

Permalink
copy: do not fail if digest mismatches
Browse files Browse the repository at this point in the history
if the computed digest mismatches the expected one, just log a warning
and use the computed one.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Jun 1, 2023
1 parent 32e1469 commit 6033259
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion copy/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ func (ic *imageCopier) copyBlobFromStream(ctx context.Context, srcReader io.Read
}

if digestingReader.validationFailed { // Coverage: This should never happen.
return types.BlobInfo{}, fmt.Errorf("Internal error writing blob %s, digest verification failed but was ignored", srcInfo.Digest)
uploadedInfo.Digest = digestingReader.digester.Digest()
logrus.Warningf("Digest verification failed for blob %s, using computed %s", srcInfo.Digest, uploadedInfo.Digest)
return uploadedInfo, nil
}
if stream.info.Digest != "" && uploadedInfo.Digest != stream.info.Digest {
return types.BlobInfo{}, fmt.Errorf("Internal error writing blob %s, blob with digest %s saved with digest %s", srcInfo.Digest, stream.info.Digest, uploadedInfo.Digest)
Expand Down
4 changes: 2 additions & 2 deletions copy/digesting_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ func (d *digestingReader) Read(p []byte) (int, error) {
actualDigest := d.digester.Digest()
if actualDigest != d.expectedDigest {
d.validationFailed = true
return 0, fmt.Errorf("Digest did not match, expected %s, got %s", d.expectedDigest, actualDigest)
} else {
d.validationSucceeded = true
}
d.validationSucceeded = true
}
return n, err
}

0 comments on commit 6033259

Please sign in to comment.