[Builder] Expose GetImage interface for builder#33054
Conversation
|
Design LGTM |
a5b6bd9 to
8c35320
Compare
|
I think I fixed the test failures. The problem was that releaseableLayer was being returned with a closer over the original image/imageID. This meant that updates to the base layer were not reflected in the layer. The change was to add an imageID to My concern is that it wouldn't really be possible to model this with a remote API. We might want to consider a separate |
8c35320 to
efa5d8d
Compare
|
As discussed privately the need for |
|
What do you mean by "backed by layer.Layer" ? There is a RWLayer underlying the releaseableLayer |
|
@dnephin Every instance of |
daemon/build.go
Outdated
There was a problem hiding this comment.
roLayer still needs to be released. Might be simpler to add a ref to roLayer in releaseableLayer instead of defining these callback methods.
There was a problem hiding this comment.
For extra safety, maybe makes sense to define a finalizer for this type.
There was a problem hiding this comment.
Oops, right. Thanks.
I don't really want to expose the daemon , so I will still need some closures. They are not really callbacks.
I guess I could use the layerStore reference
daemon/build.go
Outdated
516249d to
b4363ad
Compare
|
The build is green! I believe I've addressed the issues with roLayer in releaseableLayer as well as the bug described in #33090 Ready for another design review |
daemon/build.go
Outdated
There was a problem hiding this comment.
When an image is created from scratch and doesn't include any copy/add this chainID is empty. I'll add a comment about this with the next round of changes after design review.
I guess ill also need to add a check to Mount() and provide a better error when roLayer is nil
There was a problem hiding this comment.
Yes, Mount() seems unprotected atm. Other way would be return nil(or not call GetImage for scratch) as there is no point for keeping a reference for scratch.
There was a problem hiding this comment.
GetImage() is never called with a scratch object. But if you do FROM someimage and that image doesn't have any COPY/ADD, then this ChainID() is still the empty string.
So we have to check for that condition here. We could either return a nop implementation of ReleasableLayer, but I decided against that because many of these nil checks are required anyway. So i thought it was be easier to just add a few more instead of creating another struct.
There was a problem hiding this comment.
What about just returning nil. It could be better to detect this case here than to call Mount() and get the error. Also if we add Exec() then this takes layer as a parameter, so it would be better to detect this case before instead of passing the empty struct.
There was a problem hiding this comment.
Oh ya, that is a lot better. The case where layer is nil is already handled.
I'll leave the nil checks in mount anyway for safety
tonistiigi
left a comment
There was a problem hiding this comment.
Just some comments, overall looks good
builder/builder.go
Outdated
There was a problem hiding this comment.
If you don't want to call this GetImage then maybe ImageAndRootFS.
There was a problem hiding this comment.
It can't be GetImage because it conflicts with another daemon method already called GetImage.
I called it Layer, since the second return is named ReleaseableLayer. Should we rename that object as well? I think they should match.
Or should I make this GetImageAndReleasableLayer() ?
There was a problem hiding this comment.
Not really that important, we could also call it a snapshot and use the containerd terms.
There was a problem hiding this comment.
Ok, I'll use GetImageAndReleasableLayer() for now. It's easy to rename later when we have the ability to use snapshots. I think it will be confusing to readers if we introduce the term snapshot right now.
builder/dockerfile/dispatchers.go
Outdated
There was a problem hiding this comment.
imageMounter is bit confusing in here as regular from never mounts anything.
There was a problem hiding this comment.
That's true, but the purpose of the struct is still to manage the unmounts required because of the API we are using. I don't know what else to call it
builder/dockerfile/imagecontext.go
Outdated
There was a problem hiding this comment.
nit: what's the benefit of callback instead of using the interface dependency
There was a problem hiding this comment.
The advantage is that we don't have to store all the opts that are only used in this one place. We only need them to construct the object. By storing just the function type that relationship is clear. If we were to store all the opts it wouldn't be clear.
daemon/build.go
Outdated
There was a problem hiding this comment.
Yes, Mount() seems unprotected atm. Other way would be return nil(or not call GetImage for scratch) as there is no point for keeping a reference for scratch.
91b13fc to
73f1462
Compare
builder/builder.go
Outdated
There was a problem hiding this comment.
Not really that important, we could also call it a snapshot and use the containerd terms.
daemon/build.go
Outdated
There was a problem hiding this comment.
What about just returning nil. It could be better to detect this case here than to call Mount() and get the error. Also if we add Exec() then this takes layer as a parameter, so it would be better to detect this case before instead of passing the empty struct.
builder/dockerfile/dispatchers.go
Outdated
There was a problem hiding this comment.
re: previous comment
It isn't really that it manages unmounts. It more managers keeping the layer references. Unmount currently also happens on release but that will probably be updated. imageRefs, images, imageSources, imageCache ?
There was a problem hiding this comment.
I think we already have imageCache so I'll go with imageSources
5062290 to
1c16f09
Compare
|
I've made those changes, and CI seems to be good except for some flaky tests |
Removes 3 methods from the builder.Backend interface Remove the coupling between imageContexts, imageMounts and the builder. Signed-off-by: Daniel Nephin <[email protected]>
Signed-off-by: Daniel Nephin <[email protected]>
buildStages now tracks the imageID and runConfig for a build stage imageMounter tracks image mounts so they can released when the build ends. Signed-off-by: Daniel Nephin <[email protected]>
1c16f09 to
6c28e8e
Compare
Implement the second task in #32904
This PR removes the previous 3 Image functions from the builder.Backend interface and replaces them with a single function. Also refactors the interfaces between
imageMount,imageContects, anddispatchers.from