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 output base under /tmp. #20603

Closed
wants to merge 5 commits into from
Closed

Fix output base under /tmp. #20603

wants to merge 5 commits into from

Conversation

lberki
Copy link
Contributor

@lberki lberki commented Dec 19, 2023

Resolved symlink action outputs and param files are both fixed.

Resolved symlink action outputs and param files are both fixed.
} else if (!inputArtifact.isSourceArtifact() && sandboxSourceRoots != null) {
FileArtifactValue metadata = inputMetadataProvider.getInputMetadata(actionInput);
if (!metadata.isRemote() && metadata.getMaterializationExecPath().isPresent()) {
inputPath = processResolvedSymlink(
Copy link
Collaborator

Choose a reason for hiding this comment

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

@lberki I think that the missing case that is causing #20621 is that of a symlink to a source artifact. Since processResolvedSymlink doesn't take the source root mapping into account, it will return those symlinks unchanged, which is not correct.

I think that we would need to exercise the same logic as in L534-L545, but only if the symlink resolves to a source artifact. I am not sure how to check for the latter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I guess we can just check whether the resolved path lies under the exec root. If you don't get to work on this before the holidays, I can give it a try tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're absolutely right and in fact I discovered this independently due to some test breakages (our tests are winning!)-- by the time you wrote this, I had the fix. I pushed the latest version to #20603 . It works for me (protobuf, source tree + output base under /tmp, no disk cache). Mind also trying?

(don't look at the source code if you value your eyes, it's "hack to get all test cases green" quality and I'm not sure if all test cases are actually green)

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 for the test coverage, this is actually working now. I won't give a +1 for the control flow, but it's getting the job done ;⁠-⁠)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm kinda embarrassed having it on the public Internet, even in a pull request :)

@lberki
Copy link
Contributor Author

lberki commented Dec 21, 2023

Update: this version fixes all known bugs modulo one, which is that the root directory of tree artifacts is stat()ed twice instead of once.

It can be fixed by replacing it with treeDir.isSymbolicLink() call in constructTreeArtifactValueFromFilesystem() with stat.isSymbolicLink() but that in turn breaks RemoteActionMetadataStoreTest and BwoBIntegrationTest because RemoteActionFileSystem violates the contract of FileSystem.stat(): stat.isSymbolicLink() returns false even if the original path was a symlink (it should return true even if the stat follows symlinks)

It's arguably silly to count stat() calls but not readlink() and default implementation of resolveSymbolicLinks() throws an exception on the common path (not a symlink) so there is a lot to be done here, but all of which is way more yak shaving than I had anticipated.

@tjgq what do? I'm inclined to update the test to allow for two stat() calls, file a bug on you and call it a day.

@tjgq
Copy link
Contributor

tjgq commented Dec 21, 2023

@tjgq what do? I'm inclined to update the test to allow for two stat() calls, file a bug on you and call it a day.

See my reply in the internal CL :) I don't believe a contract is being violated. Two system calls are strictly required, so we should just fix the test assertion.

@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 Dec 22, 2023
@lberki
Copy link
Contributor Author

lberki commented Jan 2, 2024

I'll drop this. fb6658c is the eventually submitted version. Unfortunately, it's quite far from the version here (@tjgq is a meticulous reviewer!) but the basic idea is the same.

@lberki lberki closed this Jan 2, 2024
@Wyverald Wyverald deleted the lberki-fix-tmp branch February 16, 2024 03:49
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-Local-Exec Issues and PRs for the Execution (Local) team team-Performance Issues for Performance teams
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants