File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
src/main/java/hudson/plugins/ec2 Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ public long check(EC2Computer c) {
103103 long currentTime = this .clock .millis ();
104104
105105 if (currentTime > nextCheckAfter ) {
106+ attemptReconnectIfOffline (c );
106107 long intervalMins = internalCheck (c );
107108 nextCheckAfter = currentTime + TimeUnit .MINUTES .toMillis (intervalMins );
108109 return intervalMins ;
@@ -248,6 +249,17 @@ private long internalCheck(EC2Computer computer) {
248249 return CHECK_INTERVAL_MINUTES ;
249250 }
250251
252+ private void attemptReconnectIfOffline (EC2Computer computer ) {
253+ if (computer .isOffline ()) {
254+ LOGGER .warning ("EC2Computer " + computer .getName () + " is offline" );
255+ if (!computer .isConnecting ()) {
256+ // Keep retrying connection to agent until the job times out
257+ LOGGER .warning ("Attempting to reconnect EC2Computer " + computer .getName ());
258+ computer .connect (false );
259+ }
260+ }
261+ }
262+
251263 /*
252264 * Checks if there are any items in the queue that are waiting for this node explicitly.
253265 * This prevents a node from being taken offline while there are Ivy/Maven Modules waiting to build.
You can’t perform that action at this time.
0 commit comments