Browse Source

Don’t overwrite layer checksum on push

After v1.8.3 layer checksum is used for image ID
validation. Rewriting the checksums on push would
mean that next pulls will get different image IDs
and pulls may fail if its detected that same
manifest digest can now point to new image ID.

Fixes #17178

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Tonis Tiigi 9 năm trước cách đây
mục cha
commit
fb4a725692
1 tập tin đã thay đổi với 5 bổ sung3 xóa
  1. 5 3
      graph/push_v2.go

+ 5 - 3
graph/push_v2.go

@@ -169,15 +169,17 @@ func (p *v2Pusher) pushV2Tag(tag string) error {
 		// if digest was empty or not saved, or if blob does not exist on the remote repository,
 		// if digest was empty or not saved, or if blob does not exist on the remote repository,
 		// then fetch it.
 		// then fetch it.
 		if !exists {
 		if !exists {
-			if pushDigest, err := p.pushV2Image(p.repo.Blobs(context.Background()), layer); err != nil {
+			var pushDigest digest.Digest
+			if pushDigest, err = p.pushV2Image(p.repo.Blobs(context.Background()), layer); err != nil {
 				return err
 				return err
-			} else if pushDigest != dgst {
+			}
+			if dgst == "" {
 				// Cache new checksum
 				// Cache new checksum
 				if err := p.graph.SetLayerDigest(layer.ID, pushDigest); err != nil {
 				if err := p.graph.SetLayerDigest(layer.ID, pushDigest); err != nil {
 					return err
 					return err
 				}
 				}
-				dgst = pushDigest
 			}
 			}
+			dgst = pushDigest
 		}
 		}
 
 
 		// read v1Compatibility config, generate new if needed
 		// read v1Compatibility config, generate new if needed