Skip to content

[v0.25 backport] fix cache export error handling#6267

Closed
thaJeztah wants to merge 2 commits into
moby:v0.25from
thaJeztah:0.25_backport_cache_export_error_handling
Closed

[v0.25 backport] fix cache export error handling#6267
thaJeztah wants to merge 2 commits into
moby:v0.25from
thaJeztah:0.25_backport_cache_export_error_handling

Conversation

@thaJeztah
Copy link
Copy Markdown
Member


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 marshalRemote in both versions, but in this specific case it is not reached. While v0.24 there was no error, when this case was hit the return nil likely 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.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 99c6887)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
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 <tonistiigi@gmail.com>
(cherry picked from commit 77aa49d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah added this to the v0.25.1 milestone Oct 5, 2025
@tonistiigi tonistiigi closed this Oct 7, 2025
@thaJeztah thaJeztah deleted the 0.25_backport_cache_export_error_handling branch October 17, 2025 19:08
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.

2 participants