File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -729,6 +729,23 @@ func (s *stageBuilder) saveLayerToImage(layer v1.Layer, createdBy string) error
729
729
if err != nil {
730
730
return err
731
731
}
732
+
733
+ // Images in google/go-containerregistry don't support adding unique layers
734
+ // with duplicate diff IDs. For example, if the source image has an empty
735
+ // layer which has been compressed with Gzip level 3, and the layer we're
736
+ // adding is also an empty layer compressed with Gzip level 1, the diff IDs
737
+ // would match but the layer blobs would be different. This would cause an
738
+ // error when trying to upload the image to a registry as the manifest is
739
+ // referencing a blob that has been "overwritten".
740
+ diffID , err := layer .DiffID ()
741
+ if err != nil {
742
+ return errors .Wrap (err , "checking layer diffID failed" )
743
+ }
744
+ if el , err := s .image .LayerByDiffID (diffID ); err == nil {
745
+ logrus .Debugf ("Layer already exists in image, using existing layer: %s" , diffID )
746
+ layer = el
747
+ }
748
+
732
749
s .image , err = mutate .Append (s .image ,
733
750
mutate.Addendum {
734
751
Layer : layer ,
You can’t perform that action at this time.
0 commit comments