Add session callback before export completion#4139
Closed
jedevc wants to merge 1 commit intomoby:masterfrom
Closed
Add session callback before export completion#4139jedevc wants to merge 1 commit intomoby:masterfrom
jedevc wants to merge 1 commit intomoby:masterfrom
Conversation
Signed-off-by: Justin Chadwell <me@jedevc.com>
tonistiigi
reviewed
Aug 25, 2023
Member
tonistiigi
left a comment
There was a problem hiding this comment.
I'm a bit confused why this is useful for anything else than image. I thought the intention was that buildkit creates image, sends a digest to the client, and blocks until the client has handled it.
In that case it is more like the push option in the current image exporter, but instead of push=true it would be something like signalsession=sessionid.
Regarding naming, maybe session/resultcallback or something similar.
Member
Author
|
This is similar to the existing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows for more neatly adding client-side logic that allows affecting the status of the export.
For example, in buildx for the
dockerdriver, we have logic for taking the resultingtype=imageexport and pushing it to a registry: https://github.com/docker/buildx/blob/master/build/build.go#L1149. Additionally, we have follow-ups for multi-node manifest list merging https://github.com/docker/buildx/blob/master/build/build.go#L1035.Eventually, we'll also want something similar in relation to moby/moby#44369, where we'll want the client to stream content from the BuildKit image exporter's containerd store into the client's containerd store directly.
These kind of client-side exporter follow-ups are reasonably common, but currently, because the result of the build export is only available after a call to Solve, then we can't:
unpack, the results will be cleaned up by GC at some point after Solve.To resolve this, we can add a new session API - this new API will be called immediately after the exporter runs and we know whether it succeeded or failed, but before the underlying resources are cleaned up, and before
Solvesucceeds. This allows us to affect the final error message and exporter response from Solve, as well as guarantee access to any image layers/etc before they are cleaned up.A few considered alternatives:
customexporter that simply calls the client-side callback, without propagating it through each exporter. The issue is that we'd still need to duplicate much of theimageexporter to ensure that the layers we'd want to pull are present. This is also much less flexible, and can't be used everywhere.Note: this should work with #2760, so we'd likely want to modify this to include an exporter ID if we take this approach.
Naming is hard,
exportis definitely the wrong name for this new session API, but struggling to come up with anything different 😢