Merge pull request #46310 from vvoland/c8d-legacybuilder-fix-layermismatch-24

[24.0 backport] c8d/legacybuilder: Fix `mismatched image rootfs` errors
This commit is contained in:
Sebastiaan van Stijn 2023-08-24 15:03:28 +02:00 committed by GitHub
commit 8ff9ef2a7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -505,9 +505,6 @@ func (i *ImageService) CreateImage(ctx context.Context, config []byte, parent st
return nil, err
}
newImage := dimage.NewImage(dimage.ID(createdImage.Target.Digest))
newImage.V1Image = imgToCreate.V1Image
newImage.V1Image.ID = string(createdImage.Target.Digest)
newImage.History = imgToCreate.History
newImage := dimage.Clone(imgToCreate, dimage.ID(createdImage.Target.Digest))
return newImage, nil
}

View file

@ -248,6 +248,15 @@ func NewChildImage(img *Image, child ChildConfig, os string) *Image {
}
}
// Clone clones an image and changes ID.
func Clone(base *Image, id ID) *Image {
img := *base
img.RootFS = img.RootFS.Clone()
img.V1Image.ID = id.String()
img.computedID = id
return &img
}
// History stores build commands that were used to create an image
type History struct {
// Created is the timestamp at which the image was created