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

[Builder] Move file coping from the daemon to the builder #33454

Merged
merged 3 commits into from
Jun 20, 2017

Conversation

dnephin
Copy link
Member

@dnephin dnephin commented May 31, 2017

Implements items 4, 5, 6 in #32904

Removes Daemon.CopyOnBuild() and moves the copy logic to the builder

@dnephin dnephin force-pushed the refactor-builder-remove-copy-on-build branch 3 times, most recently from 0219fe7 to 20688cf Compare May 31, 2017 17:42
Config: child.Config,
Architecture: runtime.GOARCH,
OS: runtime.GOOS,
Container: child.ContainerID,
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

@@ -96,10 +94,13 @@ type ImageCache interface {
type Image interface {
ImageID() string
RunConfig() *container.Config
MarshalJSON() ([]byte, error)
NewChild(child image.ChildConfig) *image.Image
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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 {
Copy link
Member

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) {
Copy link
Member

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.

Copy link
Member Author

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() ?

Copy link
Member

@tonistiigi tonistiigi Jun 1, 2017

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)
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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
Copy link
Member

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

Copy link
Member Author

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

@dnephin dnephin force-pushed the refactor-builder-remove-copy-on-build branch 6 times, most recently from 0c30c9c to 23f4222 Compare June 5, 2017 18:15
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("")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== ""

@dnephin dnephin force-pushed the refactor-builder-remove-copy-on-build branch from b81495b to 23f4222 Compare June 5, 2017 22:06
@dnephin dnephin force-pushed the refactor-builder-remove-copy-on-build branch 2 times, most recently from aeb87d2 to 5aaeeaf Compare June 7, 2017 15:46
@tonistiigi
Copy link
Member

LGTM, with cleaning up the dependency graph in a follow-up.

dnephin added 3 commits June 8, 2017 15:06
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>
@dnephin dnephin force-pushed the refactor-builder-remove-copy-on-build branch from 5aaeeaf to 5136096 Compare June 8, 2017 19:07
@dnephin
Copy link
Member Author

dnephin commented Jun 8, 2017

rebased, and squashed down to 3 commits

@dnephin dnephin requested a review from vdemeester June 8, 2017 19:09
@dnephin
Copy link
Member Author

dnephin commented Jun 19, 2017

This need one more LGTM, PTAL

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐮

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants