Search in sources :

Example 11 with SingularityDeployMarker

use of com.hubspot.singularity.SingularityDeployMarker in project Singularity by HubSpot.

the class DeployResource method cancelDeploy.

@DELETE
@Path("/deploy/{deployId}/request/{requestId}")
@ApiOperation(value = "Cancel a pending deployment (best effort - the deploy may still succeed or fail)", response = SingularityRequestParent.class)
@ApiResponses({ @ApiResponse(code = 400, message = "Deploy is not in the pending state pending or is not not present") })
public SingularityRequestParent cancelDeploy(@Auth SingularityUser user, @ApiParam(required = true, value = "The Singularity Request Id from which the deployment is removed.") @PathParam("requestId") String requestId, @ApiParam(required = true, value = "The Singularity Deploy Id that should be removed.") @PathParam("deployId") String deployId) {
    SingularityRequestWithState requestWithState = fetchRequestWithState(requestId, user);
    authorizationHelper.checkForAuthorization(requestWithState.getRequest(), user, SingularityAuthorizationScope.WRITE);
    validator.checkActionEnabled(SingularityAction.CANCEL_DEPLOY);
    Optional<SingularityRequestDeployState> deployState = deployManager.getRequestDeployState(requestWithState.getRequest().getId());
    checkBadRequest(deployState.isPresent() && deployState.get().getPendingDeploy().isPresent() && deployState.get().getPendingDeploy().get().getDeployId().equals(deployId), "Request %s does not have a pending deploy %s", requestId, deployId);
    deployManager.createCancelDeployRequest(new SingularityDeployMarker(requestId, deployId, System.currentTimeMillis(), user.getEmail(), Optional.<String>absent()));
    return fillEntireRequest(requestWithState);
}
Also used : SingularityDeployMarker(com.hubspot.singularity.SingularityDeployMarker) SingularityRequestWithState(com.hubspot.singularity.SingularityRequestWithState) SingularityRequestDeployState(com.hubspot.singularity.SingularityRequestDeployState) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Aggregations

SingularityDeployMarker (com.hubspot.singularity.SingularityDeployMarker)11 SingularityDeploy (com.hubspot.singularity.SingularityDeploy)5 SingularityDeployResult (com.hubspot.singularity.SingularityDeployResult)4 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)4 SingularityRequest (com.hubspot.singularity.SingularityRequest)3 SingularityRequestDeployState (com.hubspot.singularity.SingularityRequestDeployState)3 SingularityDeployBuilder (com.hubspot.singularity.SingularityDeployBuilder)2 SingularityPendingDeploy (com.hubspot.singularity.SingularityPendingDeploy)2 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)2 ArrayList (java.util.ArrayList)2 SingularityCreateResult (com.hubspot.singularity.SingularityCreateResult)1 SingularityDeployHistory (com.hubspot.singularity.SingularityDeployHistory)1 SingularityDeployKey (com.hubspot.singularity.SingularityDeployKey)1 SingularityDeployProgress (com.hubspot.singularity.SingularityDeployProgress)1 SingularityDeployStatistics (com.hubspot.singularity.SingularityDeployStatistics)1 SingularityDeployUpdate (com.hubspot.singularity.SingularityDeployUpdate)1 SingularityHostState (com.hubspot.singularity.SingularityHostState)1 SingularityPendingRequest (com.hubspot.singularity.SingularityPendingRequest)1 SingularityRack (com.hubspot.singularity.SingularityRack)1 SingularityRequestHistory (com.hubspot.singularity.SingularityRequestHistory)1