diff --git a/agent/src/main/java/com/cloud/agent/Agent.java b/agent/src/main/java/com/cloud/agent/Agent.java index 23b5e790eb93..c1a9942174a6 100644 --- a/agent/src/main/java/com/cloud/agent/Agent.java +++ b/agent/src/main/java/com/cloud/agent/Agent.java @@ -1228,7 +1228,14 @@ public void doTask(final Task task) throws TaskExecutionException { logger.error("Error parsing task", e); } } else if (task.getType() == Task.Type.DISCONNECT) { - logger.debug("Executing disconnect task - {}", () -> getLinkLog(task.getLink())); + try { + // an issue has been found if reconnect immediately after disconnecting. please refer to https://github.com/apache/cloudstack/issues/8517 + // wait 5 seconds before reconnecting + logger.debug("Wait for 5 secs before reconnecting, disconnect task - {}", () -> getLinkLog(task.getLink())); + Thread.sleep(5000); + } catch (InterruptedException e) { + } + logger.debug("Executing disconnect task - {} and reconnecting", () -> getLinkLog(task.getLink())); reconnect(task.getLink()); } else if (task.getType() == Task.Type.OTHER) { processOtherTask(task);