Skip to content

Fix missing mounts in execOp cache map#2076

Merged
tonistiigi merged 3 commits into
moby:masterfrom
aaronlehmann:missing-mounts-in-cachemap
Apr 20, 2021
Merged

Fix missing mounts in execOp cache map#2076
tonistiigi merged 3 commits into
moby:masterfrom
aaronlehmann:missing-mounts-in-cachemap

Conversation

@aaronlehmann

Copy link
Copy Markdown
Collaborator

A bug in cloneExecOp prevented mounts from being included in the digest
computed for the execOp cache map. This could lead to an exec being
wrongly cached when a different mount was used for a subsequent
execution.

Repro case:
https://gist.github.com/aaronlehmann/cfeaefc028df8127fb85b9b5f9125f2d

In this example, pass2 should generate an empty diff because the /from
and /to mounts are the same busybox image. But before the fix, it uses
the cached result from pass1 (with different mounts) instead.

Signed-off-by: Aaron Lehmann [email protected]

A bug in cloneExecOp prevented mounts from being included in the digest
computed for the execOp cache map. This could lead to an exec being
wrongly cached when a different mount was used for a subsequent
execution.

Repro case:
https://gist.github.com/aaronlehmann/cfeaefc028df8127fb85b9b5f9125f2d

In this example, pass2 should generate an empty diff because the /from
and /to mounts are the same busybox image. But before the fix, it uses
the cached result from pass1 (with different mounts) instead.

Signed-off-by: Aaron Lehmann <[email protected]>
@tonistiigi

Copy link
Copy Markdown
Member

As discussed in slack, lets try to add compatibility check like https://github.com/moby/buildkit/pull/1965/files#diff-aaa2e0f79475db4b6234888b8ab5c1b440a68b397bc43003b832a33b1ad6cb85R111 for the default case like RUN cmd in Dockerfiles to minimize breakage.

Comment thread solver/llbsolver/ops/exec.go
@aaronlehmann
aaronlehmann force-pushed the missing-mounts-in-cachemap branch from f676dff to 61bb15a Compare April 14, 2021 15:53
op.Mounts[0].CacheOpt == nil &&
op.Mounts[0].SSHOpt == nil &&
op.Mounts[0].SecretOpt == nil &&
op.Mounts[0].ResultID == "" {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

When I run a simple Dockerfile through buildkit, I see the following in op.Mounts: [{"input":0,"dest":"/","output":0}]. I confirmed that this conditional works for my test case, but please make sure the exact checks make sense.

@aaronlehmann

Copy link
Copy Markdown
Collaborator Author

@tonistiigi: Is this ready to merge?

@tonistiigi
tonistiigi merged commit 8e71ac4 into moby:master Apr 20, 2021
@tonistiigi tonistiigi mentioned this pull request Apr 22, 2021
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