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

Stage repository mapping manifest as a root symlink #16652

Closed

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Nov 3, 2022

By adding the repository mapping manifest to runfiles as a root symlink, it is staged as foo.runfiles/_repo_mapping with all execution strategies. This includes sandboxed and remote execution, which previously did not stage the manifest at all.

As a side effect, runfiles libraries can now find the repository mapping manifest via rlocation("_repo_mapping").

Fixes #16643
Work towards #16124

@fmeum fmeum force-pushed the 16643-repo-mapping-root-symlink branch from 26e7211 to cbcf695 Compare November 3, 2022 19:08
@fmeum fmeum marked this pull request as ready for review November 3, 2022 19:08
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 3, 2022

@lberki @Wyverald

@fmeum fmeum changed the title Stage repository mapping manifest in sandboxes Stage repository mapping manifest as a root symlink Nov 3, 2022
@fmeum fmeum force-pushed the 16643-repo-mapping-root-symlink branch from cbcf695 to c09ed02 Compare November 3, 2022 19:09
@Wyverald Wyverald requested review from lberki and removed request for meteorcloudy November 3, 2022 19:23
@fmeum fmeum force-pushed the 16643-repo-mapping-root-symlink branch 2 times, most recently from 74c2ae1 to 9a94a20 Compare November 3, 2022 19:35
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 3, 2022

@Wyverald Had to fix a check on Windows and added another one for good measure.

@ShreeM01 ShreeM01 added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Nov 3, 2022
@lberki
Copy link
Contributor

lberki commented Nov 7, 2022

This looks reasonable:

  1. _repo_mapping cannot clash with repository names
  2. Runfiles manifests are not currently in sandboxes / remote execution so there is no prior art with which we would be inconstent with
  3. I just learned that we do create "symlink trees" on Windows by copying, which also works with this approach

I have one suggestion: this creates an extra Runfiles object, which may be a memory hog. How about adding an extra field to RunfilesSupplier and tweaking it so that it adds that to the runfiles trees it returns instead of creating that extra Runfiles instance?

@Wyverald
Copy link
Member

Wyverald commented Nov 7, 2022

to confirm, does this mean we might in some cases have exactly one of foo.runfiles/_repo_mapping and foo.repo_mapping present? And that's fine because it'll always be found by rlocation("_repo_mapping")?

@fmeum
Copy link
Collaborator Author

fmeum commented Nov 7, 2022

I have one suggestion: this creates an extra Runfiles object, which may be a memory hog. How about adding an extra field to RunfilesSupplier and tweaking it so that it adds that to the runfiles trees it returns instead of creating that extra Runfiles instance?

I will try to implement it that way as I share this concern.

to confirm, does this mean we might in some cases have exactly one of foo.runfiles/_repo_mapping and foo.repo_mapping present? And that's fine because it'll always be found by rlocation("_repo_mapping")?

Yes, with --noenable_runfiles, only foo.repo_mapping will be present, but pointed to by an entry in the runfiles manifest. rlocation("_repo_mapping") will always work (the integration test should ensure this).

@fmeum
Copy link
Collaborator Author

fmeum commented Nov 7, 2022

@lberki There are number of places that directly consume Runfiles.getRunfilesInputs and don't go through RunfilesSupplier, e.g. SymlinkTreeStrategy and SourceManifestAction. Do you have a suggestion for how I should deal with them?

@fmeum fmeum force-pushed the 16643-repo-mapping-root-symlink branch from 9a94a20 to 46f5df9 Compare November 7, 2022 21:00
@fmeum fmeum requested a review from oquenchil as a code owner November 7, 2022 21:00
@fmeum fmeum force-pushed the 16643-repo-mapping-root-symlink branch from 46f5df9 to 5a2365d Compare November 7, 2022 21:21
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 7, 2022

@lberki I pushed a commit that wires up the root symlink without allocating a new Runfiles in the most straightforward way I could find. It does seem to require passing the manifest into SourceManifestAction and SymlinkTreeAction, which is not so nice.

@fmeum
Copy link
Collaborator Author

fmeum commented Nov 8, 2022

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Nov 8, 2022
Copy link
Contributor

@lberki lberki left a comment

Choose a reason for hiding this comment

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

Yeah, this is kind of ugly, but I don't have a better idea, either (other than the previous "create new Runfiles instance" one, which I think is worse on the balance. Maybe add a comment to Runfiles.getRunfilesInputs() that explains why the repo mapping manifest can't be there?

Conceptually, the issue is that Runfiles is now two things:

  1. What a configured target propagates upwards (and there is never a repo mapping manifest there)
  2. What is put in the symlink tree (there may be a repo mapping manifest here)

So maybe the best would be to create two separate classes for these two use cases, but I won't insist.

By adding the repository mapping manifest to runfiles as a root symlink,
it is staged as `foo.runfiles/_repo_mapping` with all execution
strategies. This includes sandboxed and remote execution, which
previously did not stage the manifest at all.

As a side effect, runfiles libraries can now find the repository
mapping manifest via `rlocation("_repo_mapping")`.
@fmeum fmeum force-pushed the 16643-repo-mapping-root-symlink branch from 5a2365d to 82fa1cb Compare November 9, 2022 08:22
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 9, 2022

Maybe add a comment to Runfiles.getRunfilesInputs() that explains why the repo mapping manifest can't be there?

I added a comment.

So maybe the best would be to create two separate classes for these two use cases, but I won't insist.

Fully agree, but that would be a bit over my head right now.

@meteorcloudy
Copy link
Member

@bazel-io fork 6.0.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Nov 9, 2022
@Wyverald Wyverald added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Nov 9, 2022
@fmeum fmeum deleted the 16643-repo-mapping-root-symlink branch November 10, 2022 15:41
fmeum added a commit to fmeum/bazel that referenced this pull request Nov 10, 2022
By adding the repository mapping manifest to runfiles as a root symlink, it is staged as `foo.runfiles/_repo_mapping` with all execution strategies. This includes sandboxed and remote execution, which previously did not stage the manifest at all.

As a side effect, runfiles libraries can now find the repository mapping manifest via `rlocation("_repo_mapping")`.

Fixes bazelbuild#16643
Work towards bazelbuild#16124

Closes bazelbuild#16652.

PiperOrigin-RevId: 487532254
Change-Id: I9774b8930337c5967fce92a861cc0db71dea2f0f
fmeum added a commit to fmeum/bazel that referenced this pull request Nov 10, 2022
By adding the repository mapping manifest to runfiles as a root symlink, it is staged as `foo.runfiles/_repo_mapping` with all execution strategies. This includes sandboxed and remote execution, which previously did not stage the manifest at all.

As a side effect, runfiles libraries can now find the repository mapping manifest via `rlocation("_repo_mapping")`.

Fixes bazelbuild#16643
Work towards bazelbuild#16124

Closes bazelbuild#16652.

PiperOrigin-RevId: 487532254
Change-Id: I9774b8930337c5967fce92a861cc0db71dea2f0f
@sgowroji sgowroji removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Nov 10, 2022
Wyverald pushed a commit that referenced this pull request Nov 10, 2022
By adding the repository mapping manifest to runfiles as a root symlink, it is staged as `foo.runfiles/_repo_mapping` with all execution strategies. This includes sandboxed and remote execution, which previously did not stage the manifest at all.

As a side effect, runfiles libraries can now find the repository mapping manifest via `rlocation("_repo_mapping")`.

Fixes #16643
Work towards #16124

Closes #16652.

PiperOrigin-RevId: 487532254
Change-Id: I9774b8930337c5967fce92a861cc0db71dea2f0f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Repository mapping manifest does not exist in test sandbox
7 participants