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

Properly account for symlinks and root symlinks in repo mapping manifest #18381

Closed
wants to merge 5 commits into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented May 12, 2023

A runfiles symlink entry path/to/pkg/file -> path/to/artifact is implicitly prefixed with the workspace name and should thus result in repo mappings to the main repository being added to the repo mapping manifest, not mappings for the owner of the artifact.

A runfiles root symlink entry first_segment/path/to/pkg/file -> path/to/artifact should result result in repo mappings to the repository with canonical name equal to the first segment being added to the repo mapping manifest, if such a repository exists.

Along the way clarifies in the documentation of ctx.runfiles(symlinks = ...) that the workspace name will be prefixed implicitly.

@fmeum fmeum marked this pull request as ready for review May 12, 2023 08:44
@fmeum fmeum requested a review from a team as a code owner May 12, 2023 08:44
@fmeum fmeum requested review from katre and removed request for a team May 12, 2023 08:44
@github-actions github-actions bot added awaiting-review PR is awaiting review from an assigned reviewer team-Configurability platforms, toolchains, cquery, select(), config transitions labels May 12, 2023
@fmeum fmeum requested review from Wyverald and rickeylev and removed request for katre May 12, 2023 08:44
@fmeum fmeum force-pushed the runfiles-symlinks-manifest branch from 925193e to fa6ff81 Compare May 12, 2023 11:25
}
/** Describes the inputs {@link fingerprint} uses to aid describeKey() descriptions. */

/** Describes the inputs {@link #fingerprint} uses to aid describeKey() descriptions. */
public String describeFingerprint() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update the describeFingerprint output to note that the reported results may be slightly misleading because addNestedSetToFingerprint will fingerprint the exact underlying structure of the nested sets, not simply the logical elements in the encountered order? It's easy to look at the output and see that the values are "equal", but you can't see the underlying nested set structure that the fingerprinting uses.

This tripped me up for a day trying to diagnose an action conflict. All the inputs were logically equivalent, but some difference in the NestedSet structures caused the fingerprinting to be different.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Was this comment meant to apply to my other PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant in this PR, though I'd give the same comment in your other PR (18419, right?).

In this PR, the fingerprint() function (which is called by computeKey somewhere, right?) is being changed to call addNestedSetToFingerprint(), which will include the exact internal structure of the nested set in the fingerprint.

Meanwhile, describeFingerprint will just render the flattened, linearized, unique, elements of the nested set. The net effect is, if an action conflict occurs, you get an error like:

Action conflict:
computeKey fingerprint: 8Ef7283Ag, F83E241
files: a, b, c
symlinks: d, e, f
rootSymlinks: g, h, i

i.e. the contents of the two are shown to be identical. Which is confusing, because if they're the same, why is there a problem? But it can be hard to identify that they are the same if the output is large.

There's another case of these elsewhere, I think something to do with tree artifacts; describeFingerprint can't accurately/correctly tell what is in them. Which is fine, we just added a line to the output to mention the reported info may not be entirely accurate. Then you have a hint that when the fingerprint differs, but everything else looks the same, it might be something to do with describeFingerprint not being able to be 100% accurate, so you can dig deeper into that object to try and identify the difference another way.

}
/** Describes the inputs {@link fingerprint} uses to aid describeKey() descriptions. */

/** Describes the inputs {@link #fingerprint} uses to aid describeKey() descriptions. */
public String describeFingerprint() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I meant in this PR, though I'd give the same comment in your other PR (18419, right?).

In this PR, the fingerprint() function (which is called by computeKey somewhere, right?) is being changed to call addNestedSetToFingerprint(), which will include the exact internal structure of the nested set in the fingerprint.

Meanwhile, describeFingerprint will just render the flattened, linearized, unique, elements of the nested set. The net effect is, if an action conflict occurs, you get an error like:

Action conflict:
computeKey fingerprint: 8Ef7283Ag, F83E241
files: a, b, c
symlinks: d, e, f
rootSymlinks: g, h, i

i.e. the contents of the two are shown to be identical. Which is confusing, because if they're the same, why is there a problem? But it can be hard to identify that they are the same if the output is large.

There's another case of these elsewhere, I think something to do with tree artifacts; describeFingerprint can't accurately/correctly tell what is in them. Which is fine, we just added a line to the output to mention the reported info may not be entirely accurate. Then you have a hint that when the fingerprint differs, but everything else looks the same, it might be something to do with describeFingerprint not being able to be 100% accurate, so you can dig deeper into that object to try and identify the difference another way.

}
/** Describes the inputs {@link fingerprint} uses to aid describeKey() descriptions. */

/** Describes the inputs {@link #fingerprint} uses to aid describeKey() descriptions. */
public String describeFingerprint() {
StringBuilder sb = new StringBuilder();
sb.append(String.format("legacyExternalRunfiles: %s\n", legacyExternalRunfiles));
Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. something like this, but move it above after the "suffix" line, before when the symlinks and other nested sets are flattened and reported. (github won't let me suggest the edit on the line I want to suggest it on)

Suggested change
sb.append(String.format("legacyExternalRunfiles: %s\n", legacyExternalRunfiles));
sb.append(String.format("legacyExternalRunfiles: %s\n", legacyExternalRunfiles));
sb.append("NOTE: fingerprinting considers internal nested set structure, which is not reflected in values reported below");

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I will build this into NestedSetFingerprintCache#describeFingerprint and use that method here once #18384 has been merged. What do you think about that? It ensures that we can never miss adding that note.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@fmeum fmeum force-pushed the runfiles-symlinks-manifest branch from af5d01b to 22e7a42 Compare May 24, 2023 10:00
@fmeum fmeum requested a review from rickeylev May 24, 2023 10:00
@fmeum fmeum force-pushed the runfiles-symlinks-manifest branch from 22e7a42 to c362d2b Compare May 24, 2023 10:47
@fmeum fmeum requested a review from lberki as a code owner May 24, 2023 10:47
Copy link
Member

@Wyverald Wyverald left a comment

Choose a reason for hiding this comment

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

thanks! not having much experience with the usage of ctx.runfiles myself, I don't think I can provide much valuable feedback, but I can at least say I think I understand what this PR is doing :)

fmeum added 5 commits June 15, 2023 16:32
A runfiles symlink entry `path/to/pkg/file -> path/to/artifact` is
implicitly prefixed with the workspace name and should thus result in
repo mappings to the main repository to be added to the repo mapping
manifest, not mappings for the owner of the artifact.

A runfiles root symlink entry `first_segment/path/to/pkg/file ->
path/to/artifact` should result result in repo mappings to the repository
with canonical name equal to the first segment to be added to the repo
mapping manifest, if it exists.

Along the way clarifies in the documentation of
`ctx.runfiles(symlinks = ...)` that the workspace name will be prefixed
implicitly.
@fmeum fmeum force-pushed the runfiles-symlinks-manifest branch from c362d2b to 0c802b3 Compare June 15, 2023 14:35
@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 Jun 15, 2023
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Jun 20, 2023
@fmeum fmeum deleted the runfiles-symlinks-manifest branch June 20, 2023 16:56
@fmeum
Copy link
Collaborator Author

fmeum commented Jun 20, 2023

@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 Jun 20, 2023
@iancha1992
Copy link
Member

@bazel-io fork 6.3.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 Jun 20, 2023
@iancha1992
Copy link
Member

@fmeum Because there were several conflict merges, there may be one or more commits needed to push before we can cherry-pick this one for 6.3.0. One of the conflicts was the missing "PyBuiltins.java" file in the current "release-6.3.0" branch.

@fmeum
Copy link
Collaborator Author

fmeum commented Jun 22, 2023

@iancha1992 I think that we can't reasonably cherry-pick this change. Sorry for the late insight.

@iancha1992
Copy link
Member

@iancha1992 I think that we can't reasonably cherry-pick this change. Sorry for the late insight.

cc: @Wyverald @meteorcloudy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants