-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
925193e
to
fa6ff81
Compare
src/test/java/com/google/devtools/build/lib/analysis/RunfilesRepoMappingManifestTest.java
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/RepoMappingManifestAction.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/RepoMappingManifestAction.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java
Outdated
Show resolved
Hide resolved
src/test/java/com/google/devtools/build/lib/analysis/RunfilesRepoMappingManifestTest.java
Show resolved
Hide resolved
} | ||
/** Describes the inputs {@link fingerprint} uses to aid describeKey() descriptions. */ | ||
|
||
/** Describes the inputs {@link #fingerprint} uses to aid describeKey() descriptions. */ | ||
public String describeFingerprint() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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)
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
af5d01b
to
22e7a42
Compare
22e7a42
to
c362d2b
Compare
There was a problem hiding this 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 :)
src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java
Show resolved
Hide resolved
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.
c362d2b
to
0c802b3
Compare
@bazel-io flag |
@bazel-io fork 6.3.0 |
@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. |
@iancha1992 I think that we can't reasonably cherry-pick this change. Sorry for the late insight. |
|
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.