-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
[Builder] Move file coping from the daemon to the builder #33454
[Builder] Move file coping from the daemon to the builder #33454
Conversation
0219fe7
to
20688cf
Compare
Config: child.Config, | ||
Architecture: runtime.GOARCH, | ||
OS: runtime.GOOS, | ||
Container: child.ContainerID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just stop using that field. I don't think it is used for anything, conflicts with #30611 etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also used by commit. In that case it seems more relevant because it would be the ID of the source container.
What do you think about waiting to do this in a follow up? That way we can draw more attention to the change without the distraction of these other unrelated changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I didn't notice that builder doesn't set it. It can be follow up.
builder/builder.go
Outdated
@@ -96,10 +94,13 @@ type ImageCache interface { | |||
type Image interface { | |||
ImageID() string | |||
RunConfig() *container.Config | |||
MarshalJSON() ([]byte, error) | |||
NewChild(child image.ChildConfig) *image.Image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a conversion function AddHistory(image, history) image
to make it explicit that this does not create any parent/child relationship.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make a package that just contains the schema of the image type and directly use that pkg here instead of defining an image interface. We should not have a dependency on imagestore/layerstore though like the current image pkg has. This part could be a follow-up with a todo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to remove this from the Image
interface, I think that's a good change.
Isn't there a parent/child relationship that is established by the history?
I'm not really clear how this becomes AddHistory()
though. In addition to history, the parent image is used for:
img.RootFS
img.OSFeatures
/img.OSVersion
OSFeature/Version doesn't seem to be used for much. Do you think we could drop those as well?
Image.RootFS
would have to be exposed somewhere if we don't pass in both images to this new function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AddHistory
wasn't very clear name. I meant a function that appends to both history and rootfs array of the base image config. img.OSFeatures/OSVersion
come from the base input image that is passed in. It is also missing Config/ContainerConfig
that could be either added by this function on set manually by the caller as they carry no extra logic other than just setting a propery on a struct.
return "c411d1d", nil | ||
} | ||
|
||
func (m *MockBackend) IDMappings() *idtools.IDMappings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
daemon/build.go
Outdated
if err != nil { | ||
return "", errors.Wrap(err, "failed to create rwlayer") | ||
} | ||
|
||
return rl.rwLayer.Mount("") | ||
} | ||
|
||
func (rl *releaseableLayer) Commit() (layer.DiffID, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably return releasableLayer
. Otherwise it complicated the reference tracking as caller will need to get an image with this layer to release the current layer. You should not need to call the imagestore between steps in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I thought layer.DiffID
was probably a bad return value, but wanted to keep it as simple as possible for now.
How should the DiffID
of the new layer be exposed? Should releaseableLayer
has a method DiffID()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should releaseableLayer has a method DiffID()
Yes
daemon/build.go
Outdated
return layer.DiffID(""), err | ||
} | ||
|
||
rl.newLayer, err = rl.layerStore.Register(stream, chainID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the empty layer detection in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure what that looks like. The empty layer check is layer.IsEmpty()
? How can we do that check here and use the value in the new image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point was to check if the layer was empty in here and discard it if it was. Then you do not need to access the layer package when you are adding to the diffID array in CreateImage
. Empty commit means that rootfs part of the image config does not require updates.
@@ -76,19 +104,41 @@ func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error | |||
return err | |||
} | |||
|
|||
// Twiddle the destination when it's a relative path - meaning, make it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 102: should avoid creating a container
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, good catch. I think I resolved a merge conflict incorrectly
0c30c9c
to
23f4222
Compare
image/image.go
Outdated
|
||
// NewChildImage creates a new Image as a child of this image. | ||
func NewChildImage(img *Image, child ChildConfig) *Image { | ||
isEmptyLayer := child.DiffID == layer.DiffID("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
== ""
b81495b
to
23f4222
Compare
aeb87d2
to
5aaeeaf
Compare
LGTM, with cleaning up the dependency graph in a follow-up. |
Add CreateImage() to the daemon Refactor daemon.Comit() and expose a Image.NewChild() Update copy to use IDMappings. Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Commit the rwLayer to get the correct DiffID Refacator copy in thebuilder move more code into exportImage cleanup some windows tests Release the newly commited layer. Set the imageID on the buildStage after exporting a new image. Move archiver to BuildManager. Have ReleaseableLayer.Commit return a layer and store the Image from exportImage in the local imageSources cache Remove NewChild from image interface. Signed-off-by: Daniel Nephin <dnephin@docker.com>
5aaeeaf
to
5136096
Compare
rebased, and squashed down to 3 commits |
This need one more LGTM, PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐮
Implements items 4, 5, 6 in #32904
Removes
Daemon.CopyOnBuild()
and moves the copy logic to the builder