Skip to content

Commit

Permalink
Explicitly setup ActionFS file out err for input discovery. This is t…
Browse files Browse the repository at this point in the history
…echnically a bug in the non actionfs case, but it doesn't matter as much, since we've almost surely created the parent directories of the stdout/stderr.

PiperOrigin-RevId: 212292687
  • Loading branch information
ericfelly authored and Copybara-Service committed Sep 10, 2018
1 parent c54bb0b commit 53ad67f
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,11 @@ Iterable<Artifact> discoverInputs(
clientEnv,
env,
actionFileSystem);
if (actionFileSystem != null) {
// Note that when not using ActionFS, a global setup of the parent directories of the OutErr
// streams is sufficient.
setupActionFsFileOutErr(actionExecutionContext.getFileOutErr(), action);
}
try {
actionExecutionContext.getEventBus().post(ActionStatusMessage.analysisStrategy(action));
return action.discoverInputs(actionExecutionContext);
Expand Down Expand Up @@ -863,6 +868,18 @@ private String prependExecPhaseStats(String message) {
return progressSupplier.getProgressString() + " " + message;
}

private static void setupActionFsFileOutErr(FileOutErr fileOutErr, Action action)
throws ActionExecutionException {
try {
fileOutErr.getOutputPath().getParentDirectory().createDirectoryAndParents();
fileOutErr.getErrorPath().getParentDirectory().createDirectoryAndParents();
} catch (IOException e) {
throw new ActionExecutionException(
"failed to create output directory for output streams'" + fileOutErr.getErrorPath() + "'",
e, action, false);
}
}

/**
* Prepare, schedule, execute, and then complete the action. When this function is called, we know
* that this action needs to be executed. This function will prepare for the action's execution
Expand Down Expand Up @@ -891,15 +908,7 @@ private void prepareScheduleExecuteAndCompleteAction(
if (!usesActionFileSystem()) {
action.prepare(context.getFileSystem(), context.getExecRoot());
} else {
try {
context.getFileOutErr().getOutputPath().getParentDirectory().createDirectoryAndParents();
context.getFileOutErr().getErrorPath().getParentDirectory().createDirectoryAndParents();
} catch (IOException e) {
throw new ActionExecutionException(
"failed to create output directory for output streams'"
+ context.getFileOutErr().getErrorPath() + "'",
e, action, false);
}
setupActionFsFileOutErr(context.getFileOutErr(), action);
}
createOutputDirectories(action, context);
} catch (IOException e) {
Expand Down

0 comments on commit 53ad67f

Please sign in to comment.