Skip to content

Commit 7ad7a23

Browse files
jorgeepditommaso
andauthored
Fix Google Batch task array causes process to fail (#5780) [ci fast]
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com> Signed-off-by: jorgee <jorge.ejarque@seqera.io> Co-authored-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
1 parent 27345a6 commit 7ad7a23

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

modules/nextflow/src/main/groovy/nextflow/processor/TaskHandler.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ abstract class TaskHandler {
259259

260260
/**
261261
* Determine if a task is ready for execution or it depends on resources
262-
* e.g. container that needs to be provisionied
262+
* e.g. container that needs to be provisioned
263263
*
264264
* @return {@code true} when the task is ready for execution, {@code false} otherwise
265265
*/

plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchScriptLauncher.groovy

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class GoogleBatchScriptLauncher extends BashWrapperBuilder implements GoogleBatc
4949
private Path remoteBinDir
5050
private Set<String> buckets = new HashSet<>()
5151
private PathTrie pathTrie = new PathTrie()
52+
private boolean isArray
5253

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

126127
@Override
127128
String runCommand() {
128-
launchCommand(workDirMount)
129+
return isArray
130+
? launchArrayCommand(workDirMount)
131+
: launchCommand(workDirMount)
129132
}
130133

131134
@Override
@@ -183,6 +186,20 @@ class GoogleBatchScriptLauncher extends BashWrapperBuilder implements GoogleBatc
183186
return this
184187
}
185188

189+
GoogleBatchScriptLauncher withIsArray(boolean value) {
190+
this.isArray = value
191+
return this
192+
}
193+
194+
static String launchArrayCommand(String workDir ) {
195+
// when executing a job array run directly the command script
196+
// to prevent that all child jobs write on the same .command.*
197+
// control files, causing an issue with the gcsfuse mount
198+
// For the same reason the .command.log file is not uploaded
199+
// See https://github.com/nextflow-io/nextflow/issues/5777
200+
"/bin/bash ${workDir}/${TaskRun.CMD_SCRIPT}"
201+
}
202+
186203
static String launchCommand( String workDir ) {
187204
"trap \"{ cp ${TaskRun.CMD_LOG} ${workDir}/${TaskRun.CMD_LOG}; }\" ERR; /bin/bash ${workDir}/${TaskRun.CMD_RUN} 2>&1 | tee ${TaskRun.CMD_LOG}"
188205
}

plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchTaskHandler.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class GoogleBatchTaskHandler extends TaskHandler implements FusionAwareTask {
145145
final taskBean = task.toTaskBean()
146146
return new GoogleBatchScriptLauncher(taskBean, executor.remoteBinDir)
147147
.withConfig(executor.config)
148+
.withIsArray(task.isArray())
148149
}
149150
}
150151

0 commit comments

Comments
 (0)