Fix stale cache when using bind mount with build stage#6845
Conversation
|
@ekedaigle thanks for the PR! @nalind PTAL |
nalind
left a comment
There was a problem hiding this comment.
Well spotted, and it's pretty close to what I think we'd want to be doing for that case. The wrinkle is that the value being used in the current PR is the previous stage's image's ID (the hex part of the digest of its configuration blob), when for other source locations we use the digest of the image's manifest (including the algorithm part) or a digest over a directory tree. The image ID's still unique enough that it should cause affect cache evaluation the way we desire, though.
The way I see that being sorted would be:
- add a new map field (
imageDigestMap?) alongside the currentimageMapfield in theexecutorstructure - also set a value in the new map to
r.CommitResults.Digest.String()when the corresponding value in theimageMapis set tor.ImageIDin the current version - use the value from the new map where the
imageMapvalue is currently being consulted in the new block added by the PR
Would you be up for making those changes, or would you prefer for one of us prepare a follow-up PR? Either way, thanks for catching this!
If one of you wants to take it don't let me stop you, I'd have to get more familiar with the internals here before making the changes myself. |
|
Can you squash these together, using something like |
Signed-off-by: Eric Kedaigle <ekedaigle@mitre.org> Fix formatting
8879237 to
e6edd79
Compare
|
Sure thing, should be set now. |
|
Thanks! |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This fixes a bug where stale images would be used when using a previous build stage as a bind mount source
How to verify it
Trivial example to reproduce:
buildah build -f <dockerfile> --layers.Which issue(s) this PR fixes:
Fixes #6609
Special notes for your reviewer:
I'm not particularly familiar with this code base, this was just an annoyance I wanted to fix, so comments welcome.
Does this PR introduce a user-facing change?