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

solver: correctly set the content selector with multiple bind mounts references #4270

Merged

Conversation

jsternberg
Copy link
Collaborator

Correctly set the content based selector when multiple bind mounts refer
to the same source. Previously, a selector that referred to the root
filesystem would be ignored. This is because a blank selector refers to
the root filesystem.

When two bind mounts referred to the same dependency, one mount would
add a selector while the other would be skipped. This caused the cache
key to be only computed based on the more narrow filesystem which caused
erroneous cache hits.

Now, the creation of the selector includes the root filesystem for
consideration. It fills in / as the selector and then removes it later
so that we don't narrow the selection in an invalid way.

Fixes #4123.

@jsternberg jsternberg force-pushed the invalid-caching-multiple-bind-mounts branch from 3b7fc6c to ba6fd05 Compare September 22, 2023 17:32
@jsternberg jsternberg changed the title solver: correctly set the content based selector with bind mounts solver: correctly set the content selector with multiple bind mounts references Sep 22, 2023
@jsternberg jsternberg force-pushed the invalid-caching-multiple-bind-mounts branch from ba6fd05 to b3fc6fa Compare September 22, 2023 17:33
…references

Correctly set the content based selector when multiple bind mounts refer
to the same source. Previously, a selector that referred to the root
filesystem would be ignored. This is because a blank selector refers to
the root filesystem.

When two bind mounts referred to the same dependency, one mount would
add a selector while the other would be skipped. This caused the cache
key to be only computed based on the more narrow filesystem which caused
erroneous cache hits.

Now, the creation of the selector includes the root filesystem for
consideration. It fills in `/` as the selector and then removes it later
so that we don't narrow the selection in an invalid way.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
@jsternberg jsternberg force-pushed the invalid-caching-multiple-bind-mounts branch from b3fc6fa to dc60842 Compare September 25, 2023 18:51
@jsternberg jsternberg marked this pull request as ready for review September 25, 2023 18:51
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

This looks correct, but try to create an integration test for it as well in follow-up.

@tonistiigi tonistiigi merged commit 77b9e11 into moby:master Sep 25, 2023
@jsternberg jsternberg deleted the invalid-caching-multiple-bind-mounts branch September 25, 2023 20:03
jsternberg added a commit to jsternberg/buildkit that referenced this pull request Sep 26, 2023
This is a follow up to moby#4270 which adds an integration test for the
fixed behavior.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
jsternberg added a commit to jsternberg/buildkit that referenced this pull request Sep 27, 2023
This updates moby#4270 to add an integration test and also merge some of the
logic for how the selectors are created. Now, `toSelectors` will perform
the root path detection instead of some custom logic in `getMountDeps`.

`dedupePaths` has also been updated to check if the number of paths is 1
or less so it can avoid an allocation when the function is a no-op.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
jsternberg added a commit to jsternberg/buildkit that referenced this pull request Sep 27, 2023
This updates moby#4270 to add an integration test and also merge some of the
logic for how the selectors are created. Now, `toSelectors` will perform
the root path detection instead of some custom logic in `getMountDeps`.

`dedupePaths` has also been updated to check if the number of paths is 1
or less so it can avoid an allocation when the function is a no-op.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
jsternberg added a commit to jsternberg/buildkit that referenced this pull request Nov 15, 2023
This updates moby#4270 to add an integration test and also merge some of the
logic for how the selectors are created. Now, `toSelectors` will perform
the root path detection instead of some custom logic in `getMountDeps`.

`dedupePaths` has also been updated to check if the number of paths is 1
or less so it can avoid an allocation when the function is a no-op.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
jsternberg added a commit to jsternberg/buildkit that referenced this pull request Dec 4, 2023
This updates moby#4270 to add an integration test and also merge some of the
logic for how the selectors are created. Now, `toSelectors` will perform
the root path detection instead of some custom logic in `getMountDeps`.

`dedupePaths` has also been updated to check if the number of paths is 1
or less so it can avoid an allocation when the function is a no-op.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
jsternberg added a commit to jsternberg/buildkit that referenced this pull request Dec 4, 2023
This updates moby#4270 to add an integration test and also merge some of the
logic for how the selectors are created. Now, `toSelectors` will perform
the root path detection instead of some custom logic in `getMountDeps`.

`dedupePaths` has also been updated to check if the number of paths is 1
or less so it can avoid an allocation when the function is a no-op.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
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.

Multiple bind mounts including the entire build context causes cache problems
2 participants