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

build: wait from child targets to complete before session release #2108

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

tonistiigi
Copy link
Member

@tonistiigi tonistiigi commented Nov 7, 2023

When targets in bake are chained with named build contexts we need to wait for the second target to complete the solve before the session from first build can be released. Otherwise, the first build could already release the definition from the buildkit graph before second build starts. Normally this would not be a problem because the steps from first build should get a direct cache match but there are some edge cases with local sources where another build can take ownership of the shared destination directory and then for specific graph layout BuildKit solver would find that it can possibly match cache if it would recompute content checksums for the local source, causing it to be repulled again via session.

Because Evaluate() is called manually in this patch it might cause a small performance regression in some edge cases because all targets that are used in build contexts need to wait for the child Solve() requests to return before they can export their outputs. Additionally, there is an unlikely case that the exporter like registry does not need to pull the layer at all if Evaluate would not be called. To fix this, buildkit API side change would be needed that separates calling exporter and releasing from build graph to separate steps.

@tonistiigi tonistiigi added this to the v0.12.0 milestone Nov 7, 2023
@thaJeztah
Copy link
Member

Should the description be in the commit message as well (for future reference?)

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

🎉

The small performance penalty to solve this issue is still worth it.
Could we have an integration test for this case?

@tonistiigi
Copy link
Member Author

Could we have an integration test for this case?

The case that would actually trigger a failed build is way too complicated. I haven't been able to trigger this even manually with a made-up bake file (but we have a report with a complicated bake file that did manage to do it).

@tonistiigi tonistiigi merged commit 795dd50 into docker:master Nov 14, 2023
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants