@@ -61,39 +61,38 @@ public long check(@NonNull AzureVMComputer agentNode) {
6161 return check (agentNode , new ExecutionEngine ());
6262 }
6363
64- protected long check (final AzureVMComputer agentNode , ExecutionEngine executionEngine ) {
64+ protected long check (final AzureVMComputer agentComputer , ExecutionEngine executionEngine ) {
6565 // Determine whether we can recycle this machine.
6666 // The CRS is the way that nodes that are currently operating "correctly"
6767 // can be retained/reclaimed. Any failure modes need to be dealt with through
68- // the clean up task.
68+ // the cleanup task.
6969
70- boolean canRecycle = true ;
7170 // Node must be idle
72- canRecycle &= agentNode .isIdle ();
71+ boolean canRecycle = agentComputer .isIdle ();
7372 // The node must also be online. This also implies not temporarily disconnected
7473 // (like by a user).
75- canRecycle &= agentNode .isOnline ();
74+ canRecycle &= agentComputer .isOnline ();
7675 // The configured idle time must be > 0 (which means leave forever)
7776 canRecycle &= idleTerminationMillis > 0 ;
7877 // The number of ms it's been idle must be greater than the current idle time.
79- canRecycle &= idleTerminationMillis < (System .currentTimeMillis () - agentNode .getIdleStartMilliseconds ());
78+ canRecycle &= idleTerminationMillis < (System .currentTimeMillis () - agentComputer .getIdleStartMilliseconds ());
8079
81- if (agentNode .getNode () == null ) {
80+ if (agentComputer .getNode () == null ) {
8281 return 1 ;
8382 }
8483
85- final AzureVMAgent agent = agentNode .getNode ();
84+ final AzureVMAgent agent = agentComputer .getNode ();
8685
8786 if (canRecycle ) {
8887 LOGGER .log (Level .INFO , "Idle timeout reached for agent: {0}, action: {1}" ,
89- new Object []{agentNode .getName (), agent .isShutdownOnIdle () ? "shutdown" : "delete" });
88+ new Object []{agentComputer .getName (), agent .isShutdownOnIdle () ? "shutdown" : "delete" });
9089
9190 Callable <Void > task = () -> {
9291 // Block cleanup while we execute so the cleanup task doesn't try to take it
9392 // away (node will go offline). Also blocks cleanup in case of shutdown.
9493 agent .blockCleanUpAction ();
9594 if (agent .isShutdownOnIdle ()) {
96- LOGGER .log (Level .INFO , "Going to idleTimeout agent: {0}" , agentNode .getName ());
95+ LOGGER .log (Level .INFO , "Going to idleTimeout agent: {0}" , agentComputer .getName ());
9796 agent .shutdown (Messages ._Idle_Timeout_Shutdown ());
9897 } else {
9998 agent .deprovision (Messages ._Idle_Timeout_Delete ());
@@ -112,24 +111,31 @@ protected long check(final AzureVMComputer agentNode, ExecutionEngine executionE
112111 defaultTimeoutInSeconds
113112 ));
114113 } catch (AzureCloudException ae ) {
115- LOGGER .log (Level .WARNING , String .format ("Could not terminate or shutdown %s" , agentNode .getName ()), ae );
114+ LOGGER .log (Level .WARNING , String .format ("Could not terminate or shutdown %s" ,
115+ agentComputer .getName ()), ae );
116116 // If we have an exception, set the agent for deletion.
117117 // It's unlikely we'll be able to shut it down properly ever.
118- AzureVMAgent node = agentNode .getNode ();
118+ AzureVMAgent node = agentComputer .getNode ();
119119 if (node != null ) {
120120 node .setCleanUpAction (CleanUpAction .DELETE , Messages ._Failed_Initial_Shutdown_Or_Delete ());
121121 }
122122 } catch (Exception e ) {
123123 LOGGER .log (Level .WARNING ,
124- String .format ("Exception occurred while calling timeout on node %s" , agentNode .getName ()), e );
124+ String .format ("Exception occurred while calling timeout on node %s" ,
125+ agentComputer .getName ()), e );
125126 // If we have an exception, set the agent for deletion.
126127 // It's unlikely we'll be able to shut it down properly ever.
127- AzureVMAgent node = agentNode .getNode ();
128+ AzureVMAgent node = agentComputer .getNode ();
128129 if (node != null ) {
129130 node .setCleanUpAction (CleanUpAction .DELETE , Messages ._Failed_Initial_Shutdown_Or_Delete ());
130131 }
131132 }
132133 }
134+
135+ if (agentComputer .isOffline () && !agentComputer .isConnecting () && agentComputer .isLaunchSupported ()) {
136+ agentComputer .tryReconnect ();
137+ }
138+
133139 return 1 ;
134140 }
135141
0 commit comments