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

[6.2.0] Skip empty directories in prefetcher. #17710

Merged
merged 1 commit into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ protected Completable onErrorResumeNext(Throwable error) {
* Fetches remotely stored action outputs, that are inputs to this spawn, and stores them under
* their path in the output base.
*
* <p>The {@code inputs} may not contain any unexpanded directories.
*
* <p>This method is safe to be called concurrently from spawn runners before running any local
* spawn.
*
Expand All @@ -197,10 +199,16 @@ protected ListenableFuture<Void> prefetchFiles(
Map<SpecialArtifact, List<TreeFileArtifact>> trees = new HashMap<>();
List<ActionInput> files = new ArrayList<>();
for (ActionInput input : inputs) {
// Source artifacts don't need to be fetched.
if (input instanceof Artifact && ((Artifact) input).isSourceArtifact()) {
continue;
}

// Skip empty tree artifacts (non-empty tree artifacts should have already been expanded).
if (input.isDirectory()) {
continue;
}

if (input instanceof TreeFileArtifact) {
TreeFileArtifact treeFile = (TreeFileArtifact) input;
SpecialArtifact treeArtifact = treeFile.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,31 @@ public void treeOutputsFromLocalFileSystem_works() throws Exception {
assertValidOutputFile("out/foobar.txt", "file-1\nbar\n");
}

@Test
public void emptyTreeConsumedByLocalAction() throws Exception {
// Disable remote execution so that the empty tree artifact is prefetched.
addOptions("--modify_execution_info=Genrule=+no-remote-exec");
setDownloadToplevel();
writeOutputDirRule();
write(
"BUILD",
"load(':output_dir.bzl', 'output_dir')",
"output_dir(",
" name = 'foo',",
" manifest = ':manifest',",
")",
"genrule(",
" name = 'foobar',",
" srcs = [':foo'],",
" outs = ['foobar.txt'],",
" cmd = 'touch $@',",
")");
write("manifest"); // no files

buildTarget("//:foobar");
waitDownloads();
}

@Test
public void incrementalBuild_deleteOutputsInUnwritableParentDirectory() throws Exception {
write(
Expand Down