Skip to content

Commit

Permalink
Merge pull request #2089 from HubSpot/deploy_check_catch
Browse files Browse the repository at this point in the history
Uncaught exception should result in failed deploy
  • Loading branch information
ssalinas authored Apr 30, 2020
2 parents 3468455 + df064cf commit aeae133
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private void checkDeploy(final SingularityPendingDeploy pendingDeploy, final Lis
}

SingularityDeployResult deployResult =
getDeployResult(request, requestWithState.getState(), cancelRequest, pendingDeploy, updatePendingDeployRequest, deploy, deployMatchingTasks, allOtherMatchingTasks, inactiveDeployMatchingTasks);
getDeployResultSafe(request, requestWithState.getState(), cancelRequest, pendingDeploy, updatePendingDeployRequest, deploy, deployMatchingTasks, allOtherMatchingTasks, inactiveDeployMatchingTasks);

LOG.info("Deploy {} had result {} after {}", pendingDeployMarker, deployResult, JavaUtils.durationFromMillis(System.currentTimeMillis() - pendingDeployMarker.getTimestamp()));

Expand Down Expand Up @@ -632,6 +632,17 @@ private LoadBalancerRequestId getLoadBalancerRequestId(SingularityPendingDeploy
LoadBalancerRequestType.DEPLOY, Optional.<Integer>empty());
}

private SingularityDeployResult getDeployResultSafe(final SingularityRequest request, final RequestState requestState, final Optional<SingularityDeployMarker> cancelRequest, final SingularityPendingDeploy pendingDeploy,
final Optional<SingularityUpdatePendingDeployRequest> updatePendingDeployRequest, final Optional<SingularityDeploy> deploy, final Collection<SingularityTaskId> deployActiveTasks, final Collection<SingularityTaskId> otherActiveTasks,
final Collection<SingularityTaskId> inactiveDeployMatchingTasks) {
try {
return getDeployResult(request, requestState, cancelRequest, pendingDeploy, updatePendingDeployRequest, deploy, deployActiveTasks, otherActiveTasks, inactiveDeployMatchingTasks);
} catch (Exception e) {
LOG.error("Uncaught exception processing deploy {} - {}", pendingDeploy.getDeployMarker().getRequestId(), pendingDeploy.getDeployMarker().getDeployId(), e);
return new SingularityDeployResult(DeployState.FAILED_INTERNAL_STATE, String.format("Uncaught exception: %s", e.getMessage()));
}
}

private SingularityDeployResult getDeployResult(final SingularityRequest request, final RequestState requestState, final Optional<SingularityDeployMarker> cancelRequest, final SingularityPendingDeploy pendingDeploy,
final Optional<SingularityUpdatePendingDeployRequest> updatePendingDeployRequest, final Optional<SingularityDeploy> deploy, final Collection<SingularityTaskId> deployActiveTasks, final Collection<SingularityTaskId> otherActiveTasks,
final Collection<SingularityTaskId> inactiveDeployMatchingTasks) {
Expand Down

0 comments on commit aeae133

Please # to comment.