@@ -694,6 +694,7 @@ public void closeRead() throws IOException {
694
694
}
695
695
events .onDisconnect ();
696
696
while (true ) {
697
+ // TODO refactor various sleep statements into a common method
697
698
TimeUnit .SECONDS .sleep (10 );
698
699
// Unlike JnlpAgentEndpointResolver, we do not use $jenkins/tcpSlaveAgentListener/, as that will be a 404 if the TCP port is disabled.
699
700
URL ping = new URL (hudsonUrl , "login" );
@@ -758,11 +759,18 @@ private void innerRun(IOHub hub, SSLContext context, ExecutorService service) {
758
759
final JnlpAgentEndpoint endpoint ;
759
760
try {
760
761
endpoint = resolver .resolve ();
761
- } catch (Exception e ) {
762
- if (Boolean .getBoolean (Engine .class .getName () + ".nonFatalJnlpAgentEndpointResolutionExceptions" )) {
763
- events .status ("Could not resolve JNLP agent endpoint" , e );
762
+ } catch (IOException e ) {
763
+ if (!noReconnect ) {
764
+ events .status ("Could not locate server among " + candidateUrls + "; waiting 10 seconds before retry" , e );
765
+ // TODO refactor various sleep statements into a common method
766
+ TimeUnit .SECONDS .sleep (10 );
767
+ continue ;
764
768
} else {
765
- events .error (e );
769
+ if (Boolean .getBoolean (Engine .class .getName () + ".nonFatalJnlpAgentEndpointResolutionExceptions" )) {
770
+ events .status ("Could not resolve JNLP agent endpoint" , e );
771
+ } else {
772
+ events .error (e );
773
+ }
766
774
}
767
775
return ;
768
776
}
@@ -891,6 +899,7 @@ private JnlpEndpointResolver createEndpointResolver(List<String> jenkinsUrls) {
891
899
892
900
private void onConnectionRejected (String greeting ) throws InterruptedException {
893
901
events .status ("reconnect rejected, sleeping 10s: " , new Exception ("The server rejected the connection: " + greeting ));
902
+ // TODO refactor various sleep statements into a common method
894
903
TimeUnit .SECONDS .sleep (10 );
895
904
}
896
905
@@ -913,6 +922,7 @@ private Socket connectTcp(@NonNull JnlpAgentEndpoint endpoint) throws IOExceptio
913
922
if (retry ++>10 ) {
914
923
throw e ;
915
924
}
925
+ // TODO refactor various sleep statements into a common method
916
926
TimeUnit .SECONDS .sleep (10 );
917
927
events .status (msg +" (retrying:" +retry +")" ,e );
918
928
}
0 commit comments