use of com.hubspot.singularity.hooks.DeployAcceptanceHook in project Singularity by HubSpot.
the class SingularityDeployAcceptanceManager method getAcceptanceResults.
public Map<String, DeployAcceptanceResult> getAcceptanceResults(SingularityRequest request, SingularityDeploy deploy, SingularityPendingDeploy pendingDeploy, Collection<SingularityTaskId> activeTasksForPendingDeploy, Collection<SingularityTaskId> inactiveTasksForPendingDeploy, Collection<SingularityTaskId> otherActiveTasksForRequest) {
Map<String, DeployAcceptanceResult> results = new HashMap<>();
Map<String, DeployAcceptanceState> existing = pendingDeploy.getDeployProgress().getStepAcceptanceResults();
for (DeployAcceptanceHook hook : acceptanceHooks) {
if (!existing.containsKey(hook.getName()) || existing.get(hook.getName()) == DeployAcceptanceState.PENDING) {
try {
results.put(hook.getName(), hook.getAcceptanceResult(request, deploy, pendingDeploy, activeTasksForPendingDeploy, inactiveTasksForPendingDeploy, otherActiveTasksForRequest));
} catch (Exception e) {
LOG.error("Uncaught exception running hook {}", hook.getName(), e);
if (hook.isFailOnUncaughtException()) {
results.put(hook.getName(), new DeployAcceptanceResult(DeployAcceptanceState.FAILED, e.getMessage()));
} else {
results.put(hook.getName(), new DeployAcceptanceResult(DeployAcceptanceState.SUCCEEDED, String.format("Ignored err: %s", e.getMessage())));
}
}
}
}
return results;
}
Aggregations