Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.0 backport] c8d/legacybuilder: Fix mismatched image rootfs errors #46310

Merged
merged 1 commit into from Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions daemon/containerd/image_builder.go
Expand Up @@ -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
}
9 changes: 9 additions & 0 deletions image/image.go
Expand Up @@ -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
Expand Down