Skip to content

Commit e4414d1

Browse files
Fix agent wait before reconnect (#12153)
1 parent 243f566 commit e4414d1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,14 @@ public void doTask(final Task task) throws TaskExecutionException {
12281228
logger.error("Error parsing task", e);
12291229
}
12301230
} else if (task.getType() == Task.Type.DISCONNECT) {
1231-
logger.debug("Executing disconnect task - {}", () -> getLinkLog(task.getLink()));
1231+
try {
1232+
// an issue has been found if reconnect immediately after disconnecting.
1233+
// wait 5 seconds before reconnecting
1234+
logger.debug("Wait for 5 secs before reconnecting, disconnect task - {}", () -> getLinkLog(task.getLink()));
1235+
Thread.sleep(5000);
1236+
} catch (InterruptedException e) {
1237+
}
1238+
logger.debug("Executing disconnect task - {} and reconnecting", () -> getLinkLog(task.getLink()));
12321239
reconnect(task.getLink());
12331240
} else if (task.getType() == Task.Type.OTHER) {
12341241
processOtherTask(task);

0 commit comments

Comments
 (0)