- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.3k
fix cache export error handling #6261
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
fix cache export error handling #6261
Conversation
Signed-off-by: Tonis Tiigi <[email protected]>
Don't fail whole cache export on subbranch error. This behavior changed in v0.25, but while before error was not returned, the cache chains were either too agressively dropped or the whole exported cache chain got corrupted. Signed-off-by: Tonis Tiigi <[email protected]>
| if err != nil { | ||
| return nil, err | ||
| } | ||
| res.Release(context.TODO()) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like existing code, but there's a context available here; could this / should this be a context.WithoutCancel(ctx) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these could be updated. This is old code before WithoutCancel was a thing.
| if err != nil { | ||
| return nil, err | ||
| continue | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something to do with this error? (I see it's fully discarded); something to log, or collect in a multi-error (and have a single log or something)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could log them as warnings but v0.24 didn't log them as well, so as a regression fix I don't think this change is needed.
| if err != nil { | ||
| return nil, nil | ||
| continue | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this one
Fixes cache export error handling for the case where a blob that is part of the imported cache, but doesn't actually participate in the current build has been removed in the cache source, and fails when in it transferred to new cache on export.
Two commits. Technically, either of them solves the issue of the build failing. First commit doesn't drop any cache metadata but is specific to the error caused by the blob being removed. The second one works on any export error in the cache chain, but causes the branch that the error affects to be dropped (that may cause the parents to be dropped if there are no valid input combinations left).
This is a regression in v0.25 from cache refactor. The reason it worked before is this nil return https://github.com/moby/buildkit/blob/v0.24.0/solver/exporter.go#L201 from subchain export error. Note that there was no similar return for "subexporters". There is also "exist" check in
marshalRemotein both versions, but in this specific case it is not reached. While v0.24 there was no error, when this case was hit thereturn nillikely corrupted the exported cache chains (at least that is what happens in my reproducer). This PR seems to work correctly, blob is skipped but the rest of the updated cache is still perfectly valid.