Skip to content

Commit

Permalink
Merge pull request #1919 from HubSpot/skip-shell-cmd-prefix-for-docke…
Browse files Browse the repository at this point in the history
…r-only

Configurably skip shell command prefix for Docker tasks only.
  • Loading branch information
ssalinas committed Apr 16, 2019
2 parents 1e86910 + 7cd6458 commit d332fc3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Expand Up @@ -27,6 +27,9 @@ public class SingularityExecutorShellCommandDescriptor {
@JsonProperty
private boolean skipCommandPrefix = false;

@JsonProperty
private boolean skipCommandPrefixDockerOnly = false;

public List<SingularityExecutorShellCommandOptionDescriptor> getOptions() {
return options;
}
Expand Down Expand Up @@ -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;
}
}
Expand Up @@ -143,13 +143,15 @@ public boolean apply(SingularityExecutorShellCommandDescriptor input) {

List<String> 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());
Expand Down

0 comments on commit d332fc3

Please sign in to comment.