Skip to content

Commit

Permalink
updates for PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalinas committed Oct 6, 2016
1 parent 9d185e2 commit 7a9bde5
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 22 deletions.
Expand Up @@ -42,12 +42,12 @@ public String getUri() {
return uri; return uri;
} }


@ApiModelProperty(required = false, value="Perform healthcheck on this dynamically allocated port (e.g. 0 for first port), defaults to first port") @ApiModelProperty(required=false, value="Perform healthcheck on this dynamically allocated port (e.g. 0 for first port), defaults to first port")
public Optional<Integer> getPortIndex() { public Optional<Integer> getPortIndex() {
return portIndex; return portIndex;
} }


@ApiModelProperty(required = false, value="Perform healthcheck on this port (portIndex cannot also be used when using this setting)") @ApiModelProperty(required=false, value="Perform healthcheck on this port (portIndex cannot also be used when using this setting)")
public Optional<Long> getPortNumber() { public Optional<Long> getPortNumber() {
return portNumber; return portNumber;
} }
Expand Down Expand Up @@ -95,21 +95,22 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) { if (o == null || getClass() != o.getClass()) {
return false; return false;
} }
HealthcheckOptions that = (HealthcheckOptions) o; HealthcheckOptions options = (HealthcheckOptions) o;
return Objects.equal(uri, that.uri) && return Objects.equal(uri, options.uri) &&
Objects.equal(portIndex, that.portIndex) && Objects.equal(portIndex, options.portIndex) &&
Objects.equal(portNumber, that.portNumber) && Objects.equal(portNumber, options.portNumber) &&
Objects.equal(protocol, that.protocol) && Objects.equal(protocol, options.protocol) &&
Objects.equal(startupTimeoutSeconds, that.startupTimeoutSeconds) && Objects.equal(startupTimeoutSeconds, options.startupTimeoutSeconds) &&
Objects.equal(startupDelaySeconds, that.startupDelaySeconds) && Objects.equal(startupDelaySeconds, options.startupDelaySeconds) &&
Objects.equal(intervalSeconds, that.intervalSeconds) && Objects.equal(startupIntervalSeconds, options.startupIntervalSeconds) &&
Objects.equal(responseTimeoutSeconds, that.responseTimeoutSeconds) && Objects.equal(intervalSeconds, options.intervalSeconds) &&
Objects.equal(maxRetries, that.maxRetries); Objects.equal(responseTimeoutSeconds, options.responseTimeoutSeconds) &&
Objects.equal(maxRetries, options.maxRetries);
} }


@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(uri, portIndex, portNumber, protocol, startupTimeoutSeconds, startupDelaySeconds, intervalSeconds, responseTimeoutSeconds, maxRetries); return Objects.hashCode(uri, portIndex, portNumber, protocol, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries);
} }


@Override @Override
Expand All @@ -121,6 +122,7 @@ public String toString() {
.add("protocol", protocol) .add("protocol", protocol)
.add("startupTimeoutSeconds", startupTimeoutSeconds) .add("startupTimeoutSeconds", startupTimeoutSeconds)
.add("startupDelaySeconds", startupDelaySeconds) .add("startupDelaySeconds", startupDelaySeconds)
.add("startupIntervalSeconds", startupIntervalSeconds)
.add("intervalSeconds", intervalSeconds) .add("intervalSeconds", intervalSeconds)
.add("responseTimeoutSeconds", responseTimeoutSeconds) .add("responseTimeoutSeconds", responseTimeoutSeconds)
.add("maxRetries", maxRetries) .add("maxRetries", maxRetries)
Expand Down
Expand Up @@ -50,18 +50,39 @@ public class SingularityDeploy {
private final Optional<Map<Integer, List<SingularityMesosTaskLabel>>> mesosTaskLabels; private final Optional<Map<Integer, List<SingularityMesosTaskLabel>>> mesosTaskLabels;
private final Optional<Map<Integer, Map<String, String>>> taskEnv; private final Optional<Map<Integer, Map<String, String>>> taskEnv;


/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private final Optional<String> healthcheckUri; private final Optional<String> healthcheckUri;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private final Optional<Long> healthcheckIntervalSeconds; private final Optional<Long> healthcheckIntervalSeconds;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private final Optional<Long> healthcheckTimeoutSeconds; private final Optional<Long> healthcheckTimeoutSeconds;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private final Optional<Integer> healthcheckPortIndex; private final Optional<Integer> healthcheckPortIndex;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private final Optional<HealthcheckProtocol> healthcheckProtocol; private final Optional<HealthcheckProtocol> healthcheckProtocol;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private final Optional<Integer> healthcheckMaxRetries; private final Optional<Integer> healthcheckMaxRetries;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private final Optional<Long> healthcheckMaxTotalTimeoutSeconds; private final Optional<Long> healthcheckMaxTotalTimeoutSeconds;


Expand Down
Expand Up @@ -41,18 +41,39 @@ public class SingularityDeployBuilder {
private Optional<Map<Integer, Map<String, String>>> taskLabels; private Optional<Map<Integer, Map<String, String>>> taskLabels;
private Optional<Map<Integer, List<SingularityMesosTaskLabel>>> mesosTaskLabels; private Optional<Map<Integer, List<SingularityMesosTaskLabel>>> mesosTaskLabels;


/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private Optional<String> healthcheckUri; private Optional<String> healthcheckUri;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private Optional<Long> healthcheckIntervalSeconds; private Optional<Long> healthcheckIntervalSeconds;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private Optional<Long> healthcheckTimeoutSeconds; private Optional<Long> healthcheckTimeoutSeconds;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private Optional<Integer> healthcheckPortIndex; private Optional<Integer> healthcheckPortIndex;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private Optional<HealthcheckProtocol> healthcheckProtocol; private Optional<HealthcheckProtocol> healthcheckProtocol;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private Optional<Integer> healthcheckMaxRetries; private Optional<Integer> healthcheckMaxRetries;
/**
* @deprecated use {@link #healthcheck}
*/
@Deprecated @Deprecated
private Optional<Long> healthcheckMaxTotalTimeoutSeconds; private Optional<Long> healthcheckMaxTotalTimeoutSeconds;


Expand Down
Expand Up @@ -29,6 +29,7 @@
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.hash.Hashing; import com.google.common.hash.Hashing;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.hubspot.deploy.HealthcheckOptions;
import com.hubspot.mesos.Resources; import com.hubspot.mesos.Resources;
import com.hubspot.mesos.SingularityContainerInfo; import com.hubspot.mesos.SingularityContainerInfo;
import com.hubspot.mesos.SingularityContainerType; import com.hubspot.mesos.SingularityContainerType;
Expand Down Expand Up @@ -235,12 +236,13 @@ public SingularityDeploy checkDeploy(SingularityRequest request, SingularityDepl


if (deploy.getResources().isPresent()) { if (deploy.getResources().isPresent()) {
if (deploy.getHealthcheck().isPresent()) { if (deploy.getHealthcheck().isPresent()) {
checkBadRequest(!(deploy.getHealthcheck().get().getPortIndex().isPresent() && deploy.getHealthcheck().get().getPortNumber().isPresent()), HealthcheckOptions healthcheck = deploy.getHealthcheck().get();
checkBadRequest(!(healthcheck.getPortIndex().isPresent() && healthcheck.getPortNumber().isPresent()),
"Can only specify one of portIndex or portNumber for healthchecks"); "Can only specify one of portIndex or portNumber for healthchecks");
if (deploy.getHealthcheck().get().getPortIndex().isPresent()) { if (healthcheck.getPortIndex().isPresent()) {
checkBadRequest(deploy.getHealthcheck().get().getPortIndex().get() >= 0, "healthcheckPortIndex must be greater than 0"); checkBadRequest(healthcheck.getPortIndex().get() >= 0, "healthcheckPortIndex must be greater than 0");
checkBadRequest(deploy.getResources().get().getNumPorts() > deploy.getHealthcheck().get().getPortIndex().get(), String checkBadRequest(deploy.getResources().get().getNumPorts() > healthcheck.getPortIndex().get(), String
.format("Must request %s ports for healthcheckPortIndex %s, only requested %s", deploy.getHealthcheck().get().getPortIndex().get() + 1, deploy.getHealthcheck().get().getPortIndex().get(), .format("Must request %s ports for healthcheckPortIndex %s, only requested %s", healthcheck.getPortIndex().get() + 1, healthcheck.getPortIndex().get(),
deploy.getResources().get().getNumPorts())); deploy.getResources().get().getNumPorts()));
} }
} }
Expand Down
Expand Up @@ -60,10 +60,7 @@ public void onThrowable(Throwable t) {
} }


public void saveResult(Optional<Integer> statusCode, Optional<String> responseBody, Optional<String> errorMessage, Optional<Throwable> throwable) { public void saveResult(Optional<Integer> statusCode, Optional<String> responseBody, Optional<String> errorMessage, Optional<Throwable> throwable) {
boolean inStartup = false; boolean inStartup = throwable.isPresent() && throwable.get() instanceof ConnectException;
if (throwable.isPresent() && throwable.get() instanceof ConnectException) {
inStartup = true;
}


try { try {
SingularityTaskHealthcheckResult result = new SingularityTaskHealthcheckResult(statusCode, Optional.of(System.currentTimeMillis() - startTime), startTime, responseBody, SingularityTaskHealthcheckResult result = new SingularityTaskHealthcheckResult(statusCode, Optional.of(System.currentTimeMillis() - startTime), startTime, responseBody,
Expand Down

0 comments on commit 7a9bde5

Please sign in to comment.