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

Fix missing mounts in execOp cache map #2076

Merged
merged 3 commits into from
Apr 20, 2021

Conversation

aaronlehmann
Copy link
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 alehmann@netflix.com

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 <alehmann@netflix.com>
@tonistiigi
Copy link
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.

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
…ache bugfix

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
op.Mounts[0].CacheOpt == nil &&
op.Mounts[0].SSHOpt == nil &&
op.Mounts[0].SecretOpt == nil &&
op.Mounts[0].ResultID == "" {
Copy link
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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants