Allow shutdown requests from the Controller.

This commit is contained in:
Lampros Smyrnaios 2023-04-28 23:46:39 +03:00
parent fcd80a8f3f
commit 53ab51922a
2 changed files with 7 additions and 3 deletions

View File

@ -21,10 +21,12 @@ public class GeneralController {
private static final Logger logger = LoggerFactory.getLogger(GeneralController.class);
private final String controllerIp;
private final String shutdownOrCancelCode;
public GeneralController(@Value("${info.shutdownOrCancelCode}") String shutdownOrCancelCode) {
public GeneralController(@Value("${info.controllerIp}") String controllerIp, @Value("${info.shutdownOrCancelCode}") String shutdownOrCancelCode) {
this.controllerIp = controllerIp;
this.shutdownOrCancelCode = shutdownOrCancelCode;
}
@ -91,7 +93,7 @@ public class GeneralController {
if ( remoteAddr == null || "".equals(remoteAddr) )
remoteAddr = request.getRemoteAddr();
if ( ! (remoteAddr.equals("127.0.0.1") || remoteAddr.equals(UriBuilder.ip)) ) {
if ( ! (remoteAddr.equals("127.0.0.1") || remoteAddr.equals(UriBuilder.ip) || remoteAddr.equals(controllerIp)) ) {
logger.error(initMsg + " The request came from another IP: " + remoteAddr + " | while this worker has the IP: " + UriBuilder.ip);
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
}

View File

@ -22,7 +22,9 @@ info.workerId = XX
info.maxAssignmentsLimitPerBatch = 10000
# If the "info.maxAssignmentsBatchesToHandleBeforeShutdown" is zero, then an infinite number of assignments-batches will be handled.
info.maxAssignmentsBatchesToHandleBeforeShutdown = 0
info.controllerBaseUrl = XX
info.controllerIp = XX
into.controllerPort = XX
info.controllerBaseUrl = http://${info.controllerIp}:${info.controllerPort}/api/
info.shutdownOrCancelCode = XX