Skip to content

Commit b58a590

Browse files
authored
Propagate task.containerPlatform through Fusion container command (#7074) [ci fast]
The Fusion code path bypassed setPlatform on the container builder, so process.arch was silently dropped when Fusion was enabled. Thread the task container platform through FusionHelper.runWithContainer and apply it on the builder when present. Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
1 parent 2f7a3c4 commit b58a590

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

modules/nextflow/src/main/groovy/nextflow/executor/GridTaskHandler.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class GridTaskHandler extends TaskHandler implements FusionAwareTask {
223223
final launcher = fusionLauncher()
224224
final config = task.getContainerConfig()
225225
final containerOpts = task.config.getContainerOptions()
226-
final cmd = FusionHelper.runWithContainer(launcher, config, task.getContainer(), containerOpts, submit)
226+
final cmd = FusionHelper.runWithContainer(launcher, config, task.getContainer(), containerOpts, submit, task.getContainerPlatform())
227227
// create an inline script to launch the job execution
228228
return '#!/bin/bash\n' + submitDirective(task) + cmd + '\n'
229229
}

modules/nextflow/src/main/groovy/nextflow/executor/local/LocalTaskHandler.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class LocalTaskHandler extends TaskHandler implements FusionAwareTask {
156156
final launcher = fusionLauncher()
157157
final config = task.getContainerConfig()
158158
final containerOpts = task.config.getContainerOptions()
159-
final cmd = FusionHelper.runWithContainer(launcher, config, task.getContainer(), containerOpts, submit)
159+
final cmd = FusionHelper.runWithContainer(launcher, config, task.getContainer(), containerOpts, submit, task.getContainerPlatform())
160160
log.debug "Launch cmd line: ${cmd}"
161161

162162
final logPath = Files.createTempFile('nf-task','.log')

modules/nextflow/src/main/groovy/nextflow/fusion/FusionHelper.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,17 @@ class FusionHelper {
4343
return result!=null ? result.toString()=='true' : false
4444
}
4545

46-
static String runWithContainer(FusionScriptLauncher launcher, ContainerConfig containerConfig, String containerName, String containerOpts, List<String> runCmd) {
46+
static String runWithContainer(FusionScriptLauncher launcher, ContainerConfig containerConfig, String containerName, String containerOpts, List<String> runCmd, String containerPlatform = null) {
4747
if( !containerName )
4848
throw new IllegalArgumentException("Missing task container -- Fusion requires the task to be executed by a container process")
4949
final containerBuilder = ContainerBuilder.create(containerConfig, containerName)
5050
.addMountWorkDir(false)
5151
.addRunOptions(containerOpts)
5252
.addRunOptions(containerConfig.getFusionOptions())
5353

54+
if( containerPlatform )
55+
containerBuilder.setPlatform(containerPlatform)
56+
5457
// add fusion env vars
5558
for(Map.Entry<String,String> it : launcher.fusionEnv()) {
5659
containerBuilder.addEnv("$it.key=$it.value")

modules/nextflow/src/test/groovy/nextflow/fusion/FusionHelperTest.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ class FusionHelperTest extends Specification {
4747

4848
}
4949

50+
def 'should include container platform in fusion command' () {
51+
given:
52+
def launcher = Mock(FusionScriptLauncher)
53+
def config = new DockerConfig([:])
54+
55+
when:
56+
def result = FusionHelper.runWithContainer(launcher, config, 'image:1', null, ['echo', 'hello'], 'linux/amd64')
57+
then:
58+
1 * launcher.fusionEnv() >> [:]
59+
and:
60+
result == "docker run -i --platform linux/amd64 --rm --privileged image:1 echo 'hello'"
61+
}
62+
5063
def 'should return fusion container command' () {
5164
given:
5265
def launcher = Mock(FusionScriptLauncher) {

0 commit comments

Comments
 (0)