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

Return cache export errors of dep when mode is max. #3731

Closed
wants to merge 1 commit into from

Conversation

sipsma
Copy link
Collaborator

@sipsma sipsma commented Mar 21, 2023

@tonistiigi I'm 99% sure this isn't correct as is, just sending out for discussion.

My best guess is that the right behavior is that when mode=max we are attempting to export every record and should thus fail if anything fails.

When mode=min it looks like the code intends to try to include the export if we already have a remote for it, thus these lines: https://github.com/sipsma/buildkit/blob/a33bb54df091a95350ff1a05278eb5f9bfe24a6a/solver/exporter.go#L164-L166

? Not totally sure on that front. If it's true, then I can see why ignoring the error makes sense in that case.

Let me know if that's on the right track, happy to update further with specific error type checks and such too.

@sipsma sipsma requested a review from tonistiigi March 21, 2023 00:19
@@ -171,6 +171,12 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
for _, dep := range deps {
recs, err := dep.CacheKey.Exporter.ExportTo(ctx, t, opt)
if err != nil {
if opt.Mode == CacheExportModeMax {
Copy link
Member

Choose a reason for hiding this comment

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

So this errors on ModeMin? What is that error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From what I can tell (and I might be wrong, worth cross-checking) the calls that can return an error when recursing to deps while mode is min are:

  1. res, err := cm.backend.Load(key, v.ID)
  2. remotes, err := cm.results.LoadRemotes(ctx, res, opt.CompressionOpt, opt.Session)
  3. if err := cm.backend.WalkIDsByResult(v.ID, func(id string) error {
  4. if err := cm.backend.WalkBacklinks(id, func(id string, link CacheInfoLink) error {

Now that I've actually looked through those various methods, it seems like they all only return an error when something wrong really happened and ignore them otherwise. So given that, maybe it's actually better to just always unconditionally return the error in every mode after all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, to be clear, I have not hit any errors here in the real world. I only noticed this issue because I was reading through the code to get a better understanding of it.

@sipsma
Copy link
Collaborator Author

sipsma commented Dec 2, 2024

I ended up hitting real-world problems caused by this, closing in favor of #5560

@sipsma sipsma closed this Dec 2, 2024
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.

2 participants