From c80ab68e665fddf4de459fa186b8e3d5456f197d Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Thu, 27 Jun 2019 14:43:06 -0400 Subject: [PATCH 1/2] Proxy deploy cancellations to leader --- .../com/hubspot/singularity/resources/DeployResource.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SingularityService/src/main/java/com/hubspot/singularity/resources/DeployResource.java b/SingularityService/src/main/java/com/hubspot/singularity/resources/DeployResource.java index 1fe287d696..bb2a237a2b 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/resources/DeployResource.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/resources/DeployResource.java @@ -190,8 +190,14 @@ public SingularityRequestParent deploy(SingularityDeployRequest deployRequest, S ) public SingularityRequestParent cancelDeploy( @Parameter(hidden = true) @Auth SingularityUser user, + @Context HttpServletRequest requestContext, @Parameter(required = true, description = "The Singularity Request Id from which the deployment is removed.") @PathParam("requestId") String requestId, @Parameter(required = true, description = "The Singularity Deploy Id that should be removed.") @PathParam("deployId") String deployId) { + + return maybeProxyToLeader(requestContext, SingularityRequestParent.class, null, () -> cancelDeploy(user, requestId, deployId)); + } + + public SingularityRequestParent cancelDeploy(SingularityUser user, String requestId, String deployId) { SingularityRequestWithState requestWithState = fetchRequestWithState(requestId, user); authorizationHelper.checkForAuthorization(requestWithState.getRequest(), user, SingularityAuthorizationScope.WRITE); From 528b548c5d6eaaf8feee1e0694cdb4c4b4460f06 Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Thu, 27 Jun 2019 15:58:49 -0400 Subject: [PATCH 2/2] Same for update deploy --- .../com/hubspot/singularity/resources/DeployResource.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SingularityService/src/main/java/com/hubspot/singularity/resources/DeployResource.java b/SingularityService/src/main/java/com/hubspot/singularity/resources/DeployResource.java index bb2a237a2b..79dc663557 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/resources/DeployResource.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/resources/DeployResource.java @@ -223,7 +223,12 @@ public SingularityRequestParent cancelDeploy(SingularityUser user, String reques ) public SingularityRequestParent updatePendingDeploy( @Parameter(hidden = true) @Auth SingularityUser user, + @Context HttpServletRequest requestContext, @RequestBody(required = true) SingularityUpdatePendingDeployRequest updateRequest) { + return maybeProxyToLeader(requestContext, SingularityRequestParent.class, updateRequest, () -> updatePendingDeploy(user, updateRequest)); + } + + public SingularityRequestParent updatePendingDeploy(SingularityUser user, SingularityUpdatePendingDeployRequest updateRequest) { SingularityRequestWithState requestWithState = fetchRequestWithState(updateRequest.getRequestId(), user); authorizationHelper.checkForAuthorization(requestWithState.getRequest(), user, SingularityAuthorizationScope.WRITE);