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] Extend cache key scrubbing to Empty virtual input path #20926

Closed

Conversation

oliviernotteghem
Copy link

Empty virtual path can also contain platform specific parts, therefore they should also be subject to xplat scrubbing.

@oliviernotteghem oliviernotteghem requested a review from a team as a code owner January 17, 2024 22:20
@oliviernotteghem
Copy link
Author

cc @tjgq

@github-actions github-actions bot added team-Remote-Exec Issues and PRs for the Execution (Remote) team awaiting-review PR is awaiting review from an assigned reviewer labels Jan 17, 2024
@sgowroji sgowroji added awaiting-user-response Awaiting a response from the author and removed awaiting-review PR is awaiting review from an assigned reviewer labels Jan 18, 2024
Comment on lines +265 to +269
if (scrubber != null && input instanceof ActionInput) {
String inputPath = input.equals(VirtualActionInput.EMPTY_MARKER) ? path.getPathString() : ((ActionInput)input).getExecPathString();
if (scrubber.shouldOmitInput(inputPath)) {
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually - I am now convinced that we should always scrub by PathFragment, not byActionInput.getExecPath().

The reason is runfile trees, which are the only situation in which path != actionInput.getExecPath(): the path refers to the location in the runfiles tree (e.g. bazel-out/xxx/bin/exe.runfiles/foo/bar) while the actionInput refers to the original artifact that will be staged there (e.g. bazel-out/yyy/bin/foo/bar). If we do the matching on the actionInput, a rule to scrub bazel-out/yyy won't apply because the path has a different prefix (bazel-out/xxx). This is basically the same bug you're seeing for empty files, but it applies equally to the non-empty ones.

In light of this, could you instead:

  1. Change shouldOmitInput to take a PathFragment instead of an ActionInput
  2. Amend this logic to always match on the path (no special case required for empty markers)
  3. Amend the tests that are passing an ActionInput to shouldOmitInputs to pass in a PathFragment instead

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense. Will do this week. Thanks @tjgq !

Copy link
Contributor

Choose a reason for hiding this comment

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

@oliviernotteghem are you still working on this? It would be great if it could make it into 7.1.0 (the first RC will be out today-ish, but we still have a few days to cherry-pick it)

Copy link
Contributor

Choose a reason for hiding this comment

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

I will go ahead and do this myself, because it makes a followup change easier for me.

tjgq added a commit to tjgq/bazel that referenced this pull request Feb 22, 2024
For runfiles, the effective path differs from the one reported by the ActionInput, and could even be in a different configuration prefix (e.g., an input bazel-out/xxx/foo may appear in a runfiles tree at bazel-out/yyy/bar.runfiles/foo).

This is a more general version of bazelbuild#20926.

Fixes bazelbuild#20926.

PiperOrigin-RevId: 609327629
Change-Id: I8ff2eef626835f012091045a7a4adad52877c7e4
github-merge-queue bot pushed a commit that referenced this pull request Feb 22, 2024
#21472)

For runfiles, the effective path differs from the one reported by the
ActionInput, and could even be in a different configuration prefix
(e.g., an input bazel-out/xxx/foo may appear in a runfiles tree at
bazel-out/yyy/bar.runfiles/foo).

This is a more general version of
#20926.

Fixes #20926.

PiperOrigin-RevId: 609327629
Change-Id: I8ff2eef626835f012091045a7a4adad52877c7e4
@oliviernotteghem
Copy link
Author

Excellent! Thanks for landing this. Sorry got unexpectedly busy last week.

@iancha1992
Copy link
Member

The changes in this PR have been included in Bazel 7.1.0 RC2. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=7.1.0rc2. Thanks!

oliviernotteghem pushed a commit to uber-common/bazel that referenced this pull request Jul 8, 2024
For runfiles, the effective path differs from the one reported by the ActionInput, and could even be in a different configuration prefix (e.g., an input bazel-out/xxx/foo may appear in a runfiles tree at bazel-out/yyy/bar.runfiles/foo).

This is a more general version of bazelbuild#20926.

Fixes bazelbuild#20926.

PiperOrigin-RevId: 609327629
Change-Id: I8ff2eef626835f012091045a7a4adad52877c7e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-response Awaiting a response from the author team-Remote-Exec Issues and PRs for the Execution (Remote) team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants