Skip to content

Commit d893fb5

Browse files
authored
agent: Fixes #2633 don't wait for pending tasks on reconnection (#2638)
When agent loses connection with management server, the reconnection logic waits for any pending tasks to finish. However, when such tasks do finish they fail to send an `Answer` back to managements server. Therefore from a management server's perspective such pending operations are stuck in a FSM state and need manual removal or fixing. This is by design where management server's side cmd-answer request pattern is code/execution dependent, therefore even if the answer were to be sent when management server came back up (reconnects) the management server will fail to acknowledge and process the answer due to missing listeners or being in the exact state to handle answers. Historically, the Agent would wait to reconnect until the internal tasks complete but I found no reason why it should wait for reconnection at all. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent f663b92 commit d893fb5

1 file changed

Lines changed: 1 addition & 13 deletions

File tree

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -495,19 +495,7 @@ protected void reconnect(final Link link) {
495495

496496
_resource.disconnected();
497497

498-
final String lastConnectedHost = _shell.getConnectedHost();
499-
500-
int inProgress = 0;
501-
do {
502-
_shell.getBackoffAlgorithm().waitBeforeRetry();
503-
504-
s_logger.info("Lost connection to host: " + lastConnectedHost + ". Dealing with the remaining commands...");
505-
506-
inProgress = _inProgress.get();
507-
if (inProgress > 0) {
508-
s_logger.info("Cannot connect because we still have " + inProgress + " commands in progress.");
509-
}
510-
} while (inProgress > 0);
498+
s_logger.info("Lost connection to host: " + _shell.getConnectedHost() + ". Attempting reconnection while we still have " + _inProgress.get() + " commands in progress.");
511499

512500
_connection.stop();
513501

0 commit comments

Comments
 (0)