Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public class SingularityClient {
private static final String AGENT_DETAIL_FORMAT = AGENTS_FORMAT + "/agent/%s/details";
private static final String AGENTS_DECOMISSION_FORMAT =
AGENTS_FORMAT + "/agent/%s/decommission";
private static final String UPDATE_AGENTS_DECOMISSION_FORMAT =
AGENTS_FORMAT + "/agent/%s/decommission/update";
private static final String AGENTS_FREEZE_FORMAT = AGENTS_FORMAT + "/agent/%s/freeze";
private static final String AGENTS_ACTIVATE_FORMAT =
AGENTS_FORMAT + "/agent/%s/activate";
Expand Down Expand Up @@ -1718,6 +1720,20 @@ public void decommissionAgent(
);
}

public void updateDecommissionedAgent(
String agentId,
Optional<SingularityMachineChangeRequest> machineChangeRequest
) {
final Function<String, String> requestUri = host ->
String.format(UPDATE_AGENTS_DECOMISSION_FORMAT, getApiBase(host), agentId);

post(
requestUri,
String.format("update decommission agent %s", agentId),
Optional.of(machineChangeRequest.orElse(SingularityMachineChangeRequest.empty()))
);
}

@Deprecated
public void freezeSlave(
String agentId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ protected void decommission(
saveExpiring(decommissionRequest, user, objectId);
}

public void updateDecommissionAgent(
SingularityUser user,
String agentId,
SingularityMachineChangeRequest changeRequest
) {
authorizationHelper.checkAdminAuthorization(user);
final Optional<SingularityMachineChangeRequest> maybeChangeRequest = Optional.ofNullable(
changeRequest
);
validator.checkActionEnabled(SingularityAction.ACTIVATE_AGENT);
validator.checkActionEnabled(SingularityAction.DECOMMISSION_AGENT);

if (manager.getExpiringObject(agentId).isPresent()) {
manager.deleteExpiringObject(agentId);
saveExpiring(maybeChangeRequest, user, agentId);
}
}

protected void freeze(
String objectId,
Optional<SingularityMachineChangeRequest> freezeRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,31 @@ public void decommissionAgent(
);
}

@POST
@Path("/agent/{agentId}/decommission/update")
@Operation(summary = "Update decommission of a specific active agent")
@Consumes({ MediaType.APPLICATION_JSON })
public Response updateDecommissionAgent(
@Context HttpServletRequest requestContext,
@Parameter(hidden = true) @Auth SingularityUser user,
@Parameter(required = true, description = "Active agentId") @PathParam(
"agentId"
) String agentId,
@RequestBody(
description = "Settings related to changing the state of a agent"
) SingularityMachineChangeRequest changeRequest
) {
return maybeProxyToLeader(
requestContext,
Response.class,
changeRequest,
() -> {
super.updateDecommissionAgent(user, agentId, changeRequest);
return Response.ok().build();
}
);
}

@POST
@Path("/agent/{agentId}/freeze")
@Operation(summary = "Freeze tasks on a specific agent")
Expand Down