diff --git a/src/main/java/com/olympus/hermione/stepSolvers/ExternalAgentSolver.java b/src/main/java/com/olympus/hermione/stepSolvers/ExternalAgentSolver.java index d40b9cb..0a83e05 100644 --- a/src/main/java/com/olympus/hermione/stepSolvers/ExternalAgentSolver.java +++ b/src/main/java/com/olympus/hermione/stepSolvers/ExternalAgentSolver.java @@ -95,7 +95,7 @@ public class ExternalAgentSolver extends StepSolver { } - int maxTries = 100; + int maxTries = 500; // Pool the status GET api until it return the SUCCESS or FAILED message while(!jsonResponse.get("status").equals("COMPLETED") && !jsonResponse.get("status").equals("FAILED") && maxTries > 0){ response = restTemplate.exchange( @@ -107,16 +107,18 @@ public class ExternalAgentSolver extends StepSolver { jsonResponse = new JSONObject(response.getBody()); try { - Thread.sleep(5000); + Thread.sleep(2000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.error("Thread was interrupted", e); } - + logger.info ("Check status => Remaining tryes :" + maxTries) maxTries--; } - + + logger.info ("Stop pooling agents pod. Latest status = "+jsonResponse.get("status")); + if(jsonResponse.get("status").equals("COMPLETED")){ response = restTemplate.exchange( this.agent_base_url + "/execution_result/" + this.scenarioExecution.getId(), @@ -130,6 +132,8 @@ public class ExternalAgentSolver extends StepSolver { this.scenarioExecution.setNextStepId(this.step.getNextStepId()); }else{ + logger.error ("ERROR on pooling Agents"); + throw new Exception("Agent execution failed with status: " + jsonResponse.get("status")); }