Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pkg/executor/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,23 @@ func (s *stageBuilder) saveLayerToImage(layer v1.Layer, createdBy string) error
if err != nil {
return err
}

// Images in google/go-containerregistry don't support adding unique layers
// with duplicate diff IDs. For example, if the source image has an empty
// layer which has been compressed with Gzip level 3, and the layer we're
// adding is also an empty layer compressed with Gzip level 1, the diff IDs
// would match but the layer blobs would be different. This would cause an
// error when trying to upload the image to a registry as the manifest is
// referencing a blob that has been "overwritten".
diffID, err := layer.DiffID()
if err != nil {
return errors.Wrap(err, "checking layer diffID failed")
}
if el, err := s.image.LayerByDiffID(diffID); err == nil {
logrus.Debugf("Layer already exists in image, using existing layer: %s", diffID)
layer = el
}

s.image, err = mutate.Append(s.image,
mutate.Addendum{
Layer: layer,
Expand Down
Loading