-
-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-46515] exit the Launcher process on 4XX errors #193
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import hudson.remoting.Channel.Mode; | ||
import java.io.FileInputStream; | ||
import java.io.UnsupportedEncodingException; | ||
import java.io.FileNotFoundException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.security.KeyStore; | ||
|
@@ -480,9 +481,12 @@ public List<String> parseJnlpArguments() throws ParserConfigurationException, SA | |
|
||
if (con instanceof HttpURLConnection) { | ||
HttpURLConnection http = (HttpURLConnection) con; | ||
if(http.getResponseCode()>=400) | ||
if(http.getResponseCode()>=500) | ||
// got the error code. report that (such as 401) | ||
throw new IOException("Failed to load "+slaveJnlpURL+": "+http.getResponseCode()+" "+http.getResponseMessage()); | ||
if(http.getResponseCode()>=400) | ||
// got the error code. report that (such as 401) | ||
throw new FileNotFoundException("Failed to load "+slaveJnlpURL+": "+http.getResponseCode()+" "+http.getResponseMessage()); | ||
} | ||
|
||
Document dom; | ||
|
@@ -539,6 +543,11 @@ public List<String> parseJnlpArguments() throws ParserConfigurationException, SA | |
throw x; | ||
} else | ||
throw e; | ||
} catch (FileNotFoundException e) { | ||
System.err.println("Failing to obtain "+slaveJnlpURL); | ||
e.printStackTrace(System.err); | ||
System.err.println("Will silently exit without errors"); | ||
System.exit(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure that Exiting without errors && with the zero error code is fine here To be reviewed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea after this zero exit code is to take advantage of KostyaSha/yet-another-docker-plugin#186: Defining a docker template with a restart policy (on-failure) would keep the agent alive while it is registered at the Jenknins master. Nevertheless, if anyone finds an objection, the exit code could be setup via a new flag. I would keep in mind that this PR tries to cover a case where agents are being erased after a Jenkins restart, while the agent itself is/will be back alive (leaving zombie agents trying to reconnect). As the real issue is almost unreproducible, this PR is about a defensive behaviour. |
||
} catch (IOException e) { | ||
if (this.noReconnect) | ||
throw (IOException)new IOException("Failing to obtain "+slaveJnlpURL).initCause(e); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there is direct usage of System I/O below as well :( Maybe needs refactoring (not in this PR)