From 75d710dfd28c91608377587a8cf358e241d394b5 Mon Sep 17 00:00:00 2001 From: Gowtam Lal Date: Mon, 25 Mar 2019 16:05:52 -0400 Subject: [PATCH 1/2] Add config for skipping the shell command prefix for Docker tasks only. --- .../SingularityExecutorShellCommandDescriptor.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandDescriptor.java b/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandDescriptor.java index 3393c30699..a296ea22d0 100644 --- a/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandDescriptor.java +++ b/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandDescriptor.java @@ -27,6 +27,9 @@ public class SingularityExecutorShellCommandDescriptor { @JsonProperty private boolean skipCommandPrefix = false; + @JsonProperty + private boolean skipCommandPrefixDockerOnly = false; + public List getOptions() { return options; } @@ -58,4 +61,12 @@ public boolean isSkipCommandPrefix() { public void setSkipCommandPrefix(boolean skipCommandPrefix) { this.skipCommandPrefix = skipCommandPrefix; } + + public boolean isSkipCommandPrefixDockerOnly() { + return skipCommandPrefixDockerOnly; + } + + public void setSkipCommandPrefixDockerOnly(boolean skipCommandPrefixDockerOnly) { + this.skipCommandPrefixDockerOnly = skipCommandPrefixDockerOnly; + } } From 7cd64584659874e70329766c1d8d8acd0d6df787 Mon Sep 17 00:00:00 2001 From: Gowtam Lal Date: Mon, 25 Mar 2019 16:07:50 -0400 Subject: [PATCH 2/2] Skip shell command prefix for docker only, if configured. --- .../shells/SingularityExecutorShellCommandRunner.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandRunner.java b/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandRunner.java index 03f30c466d..931d6af480 100644 --- a/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandRunner.java +++ b/SingularityExecutor/src/main/java/com/hubspot/singularity/executor/shells/SingularityExecutorShellCommandRunner.java @@ -143,13 +143,15 @@ public boolean apply(SingularityExecutorShellCommandDescriptor input) { List command = new ArrayList<>(); - if (!shellCommandDescriptor.isSkipCommandPrefix()) { - command.addAll(executorConfiguration.getShellCommandPrefix()); - } - boolean isDocker = task.getTaskInfo().hasContainer() && task.getTaskInfo().getContainer().hasDocker(); if (isDocker) { + if (!shellCommandDescriptor.isSkipCommandPrefix() && !shellCommandDescriptor.isSkipCommandPrefixDockerOnly()) { + command.addAll(executorConfiguration.getShellCommandPrefix()); + } + command.addAll(Arrays.asList("docker", "exec", String.format("%s%s", executorConfiguration.getDockerPrefix(), task.getTaskId()))); + } else if (!shellCommandDescriptor.isSkipCommandPrefix()) { + command.addAll(executorConfiguration.getShellCommandPrefix()); } command.addAll(shellCommandDescriptor.getCommand());