From 618a7e96b706e34a65cc38faa8943d4439758fdc Mon Sep 17 00:00:00 2001 From: mklkun Date: Thu, 17 Jun 2021 17:35:47 +0100 Subject: [PATCH] Fix scaleIn process when some nodes did not have been acquired properly --- .../main/java/org/activeeon/morphemic/PAGateway.java | 12 +++++++++--- .../deployment/PAResourceManagerGateway.java | 4 ++-- .../src/main/resources/log4j.properties | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java index 52fbc52d..896c5253 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java @@ -670,9 +670,15 @@ public class PAGateway { public void removeNodes(List nodeNames, Boolean preempt) { nodeNames.forEach(nodeName -> { try { - String nodeUrl = resourceManagerGateway.searchNodes(Collections.singletonList(nodeName), true).get(0); - resourceManagerGateway.removeNode(nodeUrl, preempt); - LOGGER.info("Node " + nodeName + " with URL: " + nodeUrl + " has been removed successfully."); + List nodeURLs = resourceManagerGateway.searchNodes(Collections.singletonList(nodeName), true); + if (!nodeURLs.isEmpty()) { + String nodeUrl = nodeURLs.get(0); + resourceManagerGateway.removeNode(nodeUrl, preempt); + LOGGER.info("Node " + nodeName + " with URL: " + nodeUrl + " has been removed successfully."); + } else { + LOGGER.warn("No Nodes with tag " + nodeName + " has been found in RM. Nothing to be removed here."); + } + } catch (NotConnectedException | RestException e) { LOGGER.error(String.valueOf(e.getStackTrace())); } diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java index d51d80a8..e847790b 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java @@ -197,7 +197,7 @@ public class PAResourceManagerGateway { * @throws RestException In case a Rest exception is thrown */ public List searchNodes(List tags, boolean all) throws NotConnectedException, RestException { - LOGGER.debug("Search for nodes ..."); + LOGGER.debug("Search for nodes with tags " + tags + " ..."); List nodesUrls = new ArrayList<>(rmRestInterface.searchNodes(RMConnectionHelper.getSessionId(), tags, all)); LOGGER.debug("Nodes found: " + nodesUrls); return nodesUrls; @@ -257,7 +257,7 @@ public class PAResourceManagerGateway { * @throws PermissionRestException In case the user does not have valid permissions */ public Boolean removeNode(String nodeUrl, Boolean preempt) throws NotConnectedException, PermissionRestException { - LOGGER.debug("Removing node ..."); + LOGGER.debug("Removing node \'" + nodeUrl + "\' ..."); Boolean result = rmRestInterface.removeNode(RMConnectionHelper.getSessionId(), nodeUrl, preempt); LOGGER.info("Node removed!"); return result; diff --git a/scheduling-abstraction-layer/src/main/resources/log4j.properties b/scheduling-abstraction-layer/src/main/resources/log4j.properties index 83bd98ea..b1180c11 100644 --- a/scheduling-abstraction-layer/src/main/resources/log4j.properties +++ b/scheduling-abstraction-layer/src/main/resources/log4j.properties @@ -1,6 +1,6 @@ log4j.rootCategory=info,console -log4j.logger.org.activeeon.morphemic=info +log4j.logger.org.activeeon.morphemic=debug log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.target=System.out -- GitLab