@@ -61,38 +61,39 @@ public long check(@NonNull AzureVMComputer agentNode) {
6161 return check (agentNode , new ExecutionEngine ());
6262 }
6363
64- protected long check (final AzureVMComputer agentComputer , ExecutionEngine executionEngine ) {
64+ protected long check (final AzureVMComputer agentNode , 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 cleanup task.
68+ // the clean up task.
6969
70+ boolean canRecycle = true ;
7071 // Node must be idle
71- boolean canRecycle = agentComputer .isIdle ();
72+ canRecycle &= agentNode .isIdle ();
7273 // The node must also be online. This also implies not temporarily disconnected
7374 // (like by a user).
74- canRecycle &= agentComputer .isOnline ();
75+ canRecycle &= agentNode .isOnline ();
7576 // The configured idle time must be > 0 (which means leave forever)
7677 canRecycle &= idleTerminationMillis > 0 ;
7778 // The number of ms it's been idle must be greater than the current idle time.
78- canRecycle &= idleTerminationMillis < (System .currentTimeMillis () - agentComputer .getIdleStartMilliseconds ());
79+ canRecycle &= idleTerminationMillis < (System .currentTimeMillis () - agentNode .getIdleStartMilliseconds ());
7980
80- if (agentComputer .getNode () == null ) {
81+ if (agentNode .getNode () == null ) {
8182 return 1 ;
8283 }
8384
84- final AzureVMAgent agent = agentComputer .getNode ();
85+ final AzureVMAgent agent = agentNode .getNode ();
8586
8687 if (canRecycle ) {
8788 LOGGER .log (Level .INFO , "Idle timeout reached for agent: {0}, action: {1}" ,
88- new Object []{agentComputer .getName (), agent .isShutdownOnIdle () ? "shutdown" : "delete" });
89+ new Object []{agentNode .getName (), agent .isShutdownOnIdle () ? "shutdown" : "delete" });
8990
9091 Callable <Void > task = () -> {
9192 // Block cleanup while we execute so the cleanup task doesn't try to take it
9293 // away (node will go offline). Also blocks cleanup in case of shutdown.
9394 agent .blockCleanUpAction ();
9495 if (agent .isShutdownOnIdle ()) {
95- LOGGER .log (Level .INFO , "Going to idleTimeout agent: {0}" , agentComputer .getName ());
96+ LOGGER .log (Level .INFO , "Going to idleTimeout agent: {0}" , agentNode .getName ());
9697 agent .shutdown (Messages ._Idle_Timeout_Shutdown ());
9798 } else {
9899 agent .deprovision (Messages ._Idle_Timeout_Delete ());
@@ -111,31 +112,24 @@ protected long check(final AzureVMComputer agentComputer, ExecutionEngine execut
111112 defaultTimeoutInSeconds
112113 ));
113114 } catch (AzureCloudException ae ) {
114- LOGGER .log (Level .WARNING , String .format ("Could not terminate or shutdown %s" ,
115- agentComputer .getName ()), ae );
115+ LOGGER .log (Level .WARNING , String .format ("Could not terminate or shutdown %s" , agentNode .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 = agentComputer .getNode ();
118+ AzureVMAgent node = agentNode .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" ,
125- agentComputer .getName ()), e );
124+ String .format ("Exception occurred while calling timeout on node %s" , agentNode .getName ()), e );
126125 // If we have an exception, set the agent for deletion.
127126 // It's unlikely we'll be able to shut it down properly ever.
128- AzureVMAgent node = agentComputer .getNode ();
127+ AzureVMAgent node = agentNode .getNode ();
129128 if (node != null ) {
130129 node .setCleanUpAction (CleanUpAction .DELETE , Messages ._Failed_Initial_Shutdown_Or_Delete ());
131130 }
132131 }
133132 }
134-
135- if (agentComputer .isOffline () && !agentComputer .isConnecting () && agentComputer .isLaunchSupported ()) {
136- agentComputer .tryReconnect ();
137- }
138-
139133 return 1 ;
140134 }
141135
0 commit comments