@Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String name = options.getString(nameArg.getDest()); final RemoveDeploymentGroupResponse status = client.removeDeploymentGroup(name).get(); if (status == null) { throw new RuntimeException("The Helios master could not remove the given deployment group."); } final boolean failed = status.getStatus() != RemoveDeploymentGroupResponse.Status.REMOVED; if (json) { out.println(status.toJsonString()); } else { if (failed) { out.println(format("Failed to remove deployment-group %s, status: %s", name, status.getStatus())); } else { out.println(format("Deployment-group %s removed", name)); } } return failed ? 1 : 0; } }
@DELETE @Path("/{name}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Response removeDeploymentGroup(@PathParam("name") @Valid final String name) { try { model.removeDeploymentGroup(name); return Response.ok(new RemoveDeploymentGroupResponse( RemoveDeploymentGroupResponse.Status.REMOVED)).build(); } catch (final DeploymentGroupDoesNotExistException e) { return Response.ok(new RemoveDeploymentGroupResponse( RemoveDeploymentGroupResponse.Status.DEPLOYMENT_GROUP_NOT_FOUND)).build(); } }
@Test public void testRemoveDeploymentGroupInactive() throws Exception { cli("create-deployment-group", "--json", TEST_GROUP, TEST_LABEL); cli("rolling-update", "--async", "--migrate", testJobNameAndVersion, TEST_GROUP); final RemoveDeploymentGroupResponse response = defaultClient().removeDeploymentGroup(TEST_GROUP).get(); assertEquals(RemoveDeploymentGroupResponse.Status.REMOVED, response.getStatus()); }
@Test public void testRemoveDeploymentGroupActive() throws Exception { final String host = testHost(); startDefaultAgent(host, "--labels", TEST_LABEL); // Wait for agent to come up final HeliosClient client = defaultClient(); awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS); // Use an invalid image to make sure the DG doesn't succeed (this ensure the DG will be active // for 5+ minutes, which is plenty of time). final JobId jobId = createJob(testJobName, testJobVersion, "invalid_image", IDLE_COMMAND); cli("create-deployment-group", "--json", TEST_GROUP, TEST_LABEL); cli("rolling-update", "--async", "--migrate", testJobNameAndVersion, TEST_GROUP); final RemoveDeploymentGroupResponse response = defaultClient().removeDeploymentGroup(TEST_GROUP).get(); assertEquals(RemoveDeploymentGroupResponse.Status.REMOVED, response.getStatus()); } }
@Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String name = options.getString(nameArg.getDest()); final RemoveDeploymentGroupResponse status = client.removeDeploymentGroup(name).get(); if (status == null) { throw new RuntimeException("The Helios master could not remove the given deployment group."); } final boolean failed = status.getStatus() != RemoveDeploymentGroupResponse.Status.REMOVED; if (json) { out.println(status.toJsonString()); } else { if (failed) { out.println(format("Failed to remove deployment-group %s, status: %s", name, status.getStatus())); } else { out.println(format("Deployment-group %s removed", name)); } } return failed ? 1 : 0; } }
@DELETE @Path("/{name}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Response removeDeploymentGroup(@PathParam("name") @Valid final String name) { try { model.removeDeploymentGroup(name); return Response.ok(new RemoveDeploymentGroupResponse( RemoveDeploymentGroupResponse.Status.REMOVED)).build(); } catch (final DeploymentGroupDoesNotExistException e) { return Response.ok(new RemoveDeploymentGroupResponse( RemoveDeploymentGroupResponse.Status.DEPLOYMENT_GROUP_NOT_FOUND)).build(); } }