Skip to content

Commit

Permalink
Fix Google Batch task array causes process to fail (#5780) [ci fast]
Browse files Browse the repository at this point in the history

Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: jorgee <[email protected]>
Co-authored-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
jorgee and pditommaso authored Feb 11, 2025
1 parent 27345a6 commit 7ad7a23
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ abstract class TaskHandler {

/**
* Determine if a task is ready for execution or it depends on resources
* e.g. container that needs to be provisionied
* e.g. container that needs to be provisioned
*
* @return {@code true} when the task is ready for execution, {@code false} otherwise
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GoogleBatchScriptLauncher extends BashWrapperBuilder implements GoogleBatc
private Path remoteBinDir
private Set<String> buckets = new HashSet<>()
private PathTrie pathTrie = new PathTrie()
private boolean isArray

/* ONLY FOR TESTING - DO NOT USE */
protected GoogleBatchScriptLauncher() {}
Expand Down Expand Up @@ -125,7 +126,9 @@ class GoogleBatchScriptLauncher extends BashWrapperBuilder implements GoogleBatc

@Override
String runCommand() {
launchCommand(workDirMount)
return isArray
? launchArrayCommand(workDirMount)
: launchCommand(workDirMount)
}

@Override
Expand Down Expand Up @@ -183,6 +186,20 @@ class GoogleBatchScriptLauncher extends BashWrapperBuilder implements GoogleBatc
return this
}

GoogleBatchScriptLauncher withIsArray(boolean value) {
this.isArray = value
return this
}

static String launchArrayCommand(String workDir ) {
// when executing a job array run directly the command script
// to prevent that all child jobs write on the same .command.*
// control files, causing an issue with the gcsfuse mount
// For the same reason the .command.log file is not uploaded
// See https://github.com/nextflow-io/nextflow/issues/5777
"/bin/bash ${workDir}/${TaskRun.CMD_SCRIPT}"
}

static String launchCommand( String workDir ) {
"trap \"{ cp ${TaskRun.CMD_LOG} ${workDir}/${TaskRun.CMD_LOG}; }\" ERR; /bin/bash ${workDir}/${TaskRun.CMD_RUN} 2>&1 | tee ${TaskRun.CMD_LOG}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class GoogleBatchTaskHandler extends TaskHandler implements FusionAwareTask {
final taskBean = task.toTaskBean()
return new GoogleBatchScriptLauncher(taskBean, executor.remoteBinDir)
.withConfig(executor.config)
.withIsArray(task.isArray())
}
}

Expand Down

0 comments on commit 7ad7a23

Please sign in to comment.