Skip to content

history: make sure build record is finalized before exporting #3152

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

Merged
merged 2 commits into from
May 13, 2025

Conversation

crazy-max
Copy link
Member

fixes #3149

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

As discussed offline:

  • Finalize should only happen if Trace==nil
  • For export, we can leave some opt-in mechanism to force finalize, so we don't need a sleep to wait for the client traces to finish up if the user can already confirm it.

@crazy-max crazy-max force-pushed the history-export-finalize branch from 01e93be to 7d47527 Compare May 12, 2025 14:27
@crazy-max crazy-max requested a review from tonistiigi May 12, 2025 18:41
@crazy-max crazy-max force-pushed the history-export-finalize branch from 7d47527 to 0d9dac8 Compare May 13, 2025 09:32
@crazy-max crazy-max force-pushed the history-export-finalize branch 6 times, most recently from 23cd56d to b8b6ac6 Compare May 13, 2025 11:18
Comment on lines +253 to +269
for _, node := range nodes {
node := node
eg.Go(func() error {
if node.Driver == nil {
return nil
}
c, err := node.Driver.Client(ctx)
if err != nil {
return err
}
_, err = c.ControlClient().UpdateBuildHistory(ctx, &controlapi.UpdateBuildHistoryRequest{
Ref: ref,
Finalize: true,
})
return err
})
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@tonistiigi For multi-node case I think this is safe even if the ref doesn't exist on unrelated node: https://github.com/moby/buildkit/blob/b46daef219fd318bd0f9c8f630472af771b2bb4a/solver/llbsolver/history.go#L676-L686

}
}
}
recs, err = queryRecords(ctx, ref, nodes, &queryOptions{
Copy link
Member

Choose a reason for hiding this comment

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

only do this if some records were finalized

Copy link
Member Author

Choose a reason for hiding this comment

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

🙈

### <a name="finalize"></a> Ensure build records are finalized before exporting (--finalize)

Clients can report their own traces concurrently and not all traces may be
finalized when a build is completed. Use the `--finalize` flag to ensure all
Copy link
Member

Choose a reason for hiding this comment

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

"not all traces may be
saved yet by the time of the export"

@crazy-max crazy-max added this to the v0.24.0 milestone May 13, 2025
@crazy-max crazy-max force-pushed the history-export-finalize branch from b8b6ac6 to bc30077 Compare May 13, 2025 15:08
@crazy-max crazy-max force-pushed the history-export-finalize branch from bc30077 to 68ce10c Compare May 13, 2025 15:17
@tonistiigi tonistiigi merged commit 277548e into docker:master May 13, 2025
140 checks passed
@crazy-max crazy-max deleted the history-export-finalize branch May 13, 2025 21:29
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.

Finalize records before exporting
2 participants