Skip to content

Commit

Permalink
Merge pull request #1049 from HubSpot/shell_setting
Browse files Browse the repository at this point in the history
don't set shell if arguments list is empty, ability to override shell
  • Loading branch information
ssalinas committed May 20, 2016
2 parents 61ee1fa + 78ab92c commit 698c8f9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class SingularityDeploy {
private final Optional<Integer> deployStepWaitTimeMs;
private final Optional<Boolean> autoAdvanceDeploySteps;
private final Optional<Integer> maxTaskRetries;
private final Optional<Boolean> shell;

public static SingularityDeployBuilder newBuilder(String requestId, String id) {
return new SingularityDeployBuilder(requestId, id);
Expand Down Expand Up @@ -113,7 +114,8 @@ public SingularityDeploy(@JsonProperty("requestId") String requestId,
@JsonProperty("deployInstanceCountPerStep") Optional<Integer> deployInstanceCountPerStep,
@JsonProperty("deployStepWaitTimeMs") Optional<Integer> deployStepWaitTimeMs,
@JsonProperty("autoAdvanceDeploySteps") Optional<Boolean> autoAdvanceDeploySteps,
@JsonProperty("maxTaskRetries") Optional<Integer> maxTaskRetries) {
@JsonProperty("maxTaskRetries") Optional<Integer> maxTaskRetries,
@JsonProperty("shell") Optional<Boolean> shell) {
this.requestId = requestId;

this.command = command;
Expand Down Expand Up @@ -163,6 +165,7 @@ public SingularityDeploy(@JsonProperty("requestId") String requestId,
this.deployStepWaitTimeMs = deployStepWaitTimeMs;
this.autoAdvanceDeploySteps = autoAdvanceDeploySteps;
this.maxTaskRetries = maxTaskRetries;
this.shell = shell;
}

public SingularityDeployBuilder toBuilder() {
Expand Down Expand Up @@ -203,7 +206,8 @@ public SingularityDeployBuilder toBuilder() {
.setDeployInstanceCountPerStep(deployInstanceCountPerStep)
.setDeployStepWaitTimeMs(deployStepWaitTimeMs)
.setAutoAdvanceDeploySteps(autoAdvanceDeploySteps)
.setMaxTaskRetries(maxTaskRetries);
.setMaxTaskRetries(maxTaskRetries)
.setShell(shell);
}

@ApiModelProperty(required=false, value="Number of seconds that Singularity waits for this service to become healthy (for it to download artifacts, start running, and optionally pass healthchecks.)")
Expand Down Expand Up @@ -400,6 +404,11 @@ public Optional<Integer> getMaxTaskRetries() {
return maxTaskRetries;
}

@ApiModelProperty(required=false, value="Override the shell property on the mesos task")
public Optional<Boolean> getShell() {
return shell;
}

@Override
public String toString() {
return "SingularityDeploy{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class SingularityDeployBuilder {
private Optional<Integer> deployStepWaitTimeMs;
private Optional<Boolean> autoAdvanceDeploySteps;
private Optional<Integer> maxTaskRetries;
private Optional<Boolean> shell;

public SingularityDeployBuilder(String requestId, String id) {
this.requestId = requestId;
Expand Down Expand Up @@ -103,13 +104,14 @@ public SingularityDeployBuilder(String requestId, String id) {
this.deployStepWaitTimeMs = Optional.absent();
this.autoAdvanceDeploySteps = Optional.absent();
this.maxTaskRetries = Optional.absent();
this.shell = Optional.absent();
}

public SingularityDeploy build() {
return new SingularityDeploy(requestId, id, command, arguments, containerInfo, customExecutorCmd, customExecutorId, customExecutorSource, customExecutorResources, customExecutorUser, resources,
env, uris, metadata, executorData, version, timestamp, labels, deployHealthTimeoutSeconds, healthcheckUri, healthcheckIntervalSeconds, healthcheckTimeoutSeconds, healthcheckPortIndex, healthcheckMaxRetries,
healthcheckMaxTotalTimeoutSeconds, serviceBasePath, loadBalancerGroups, loadBalancerPortIndex, considerHealthyAfterRunningForSeconds, loadBalancerOptions, loadBalancerDomains, loadBalancerAdditionalRoutes,
loadBalancerTemplate, skipHealthchecksOnDeploy, healthcheckProtocol, deployInstanceCountPerStep, deployStepWaitTimeMs, autoAdvanceDeploySteps, maxTaskRetries);
loadBalancerTemplate, skipHealthchecksOnDeploy, healthcheckProtocol, deployInstanceCountPerStep, deployStepWaitTimeMs, autoAdvanceDeploySteps, maxTaskRetries, shell);
}

public String getRequestId() {
Expand Down Expand Up @@ -458,6 +460,15 @@ public SingularityDeployBuilder setMaxTaskRetries(Optional<Integer> maxTaskRetri
return this;
}

public Optional<Boolean> getShell() {
return shell;
}

public SingularityDeployBuilder setShell(Optional<Boolean> shell) {
this.shell = shell;
return this;
}

@Override
public String toString() {
return "SingularityDeployBuilder{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,13 @@ private void prepareCommand(final TaskInfo.Builder bldr, final SingularityTaskId
commandBldr.addAllArguments(task.getPendingTask().getCmdLineArgsList().get());
}

if (task.getDeploy().getArguments().isPresent() ||
if (task.getDeploy().getShell().isPresent()){
commandBldr.setShell(task.getDeploy().getShell().get());
} else if ((task.getDeploy().getArguments().isPresent() && !task.getDeploy().getArguments().get().isEmpty()) ||
// Hopefully temporary workaround for
// http://www.mail-archive.com/user@mesos.apache.org/msg01449.html
task.getDeploy().getContainerInfo().isPresent() ||
task.getPendingTask().getCmdLineArgsList().isPresent()) {
(task.getPendingTask().getCmdLineArgsList().isPresent() && !task.getPendingTask().getCmdLineArgsList().get().isEmpty())) {
commandBldr.setShell(false);
}

Expand Down

0 comments on commit 698c8f9

Please sign in to comment.