-
Notifications
You must be signed in to change notification settings - Fork 318
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-72592] Fix inbound agent connector NPE on Jenkins 2.437+ #1049
[JENKINS-72592] Fix inbound agent connector NPE on Jenkins 2.437+ #1049
Conversation
@@ -43,22 +42,14 @@ public class DockerComputerJNLPConnector extends DockerComputerConnector { | |||
@CheckForNull | |||
private String user; | |||
|
|||
private final JNLPLauncher jnlpLauncher; |
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.
Note that removing this (and the usage in beforeContainerCreated
etc.) would be incompatible for anyone who was actually using the tunnel
field using GUI or otherwise XML config. I suspect this option is rarely used (specialized network configuration). Could be restored for compatibility if it seems important.
Other much more obvious fields of JNLPLauncher
—webSocket
, workDir
—were not interpreted at all, so anyone requiring them would I guess have had to put the corresponding options directly into entryPointArguments
(as they would now need to to with -tunnel
).
public DockerComputerJNLPConnector(JNLPLauncher jnlpLauncher) { | ||
this.jnlpLauncher = jnlpLauncher; | ||
public DockerComputerJNLPConnector() { |
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.
Incompatible for JCasC users configuring this connector using something like
connector:
jnlp:
jnlpLauncher: inbound
which should now be (I guess) just
connector: jnlp
Not sure exactly, without test coverage. Possibly though awkward to restore compatibility by adding a getter/setter that are not @Deprecated
, as in the core PR. This is assuming again that tunnel
was not actually configured this way.
I'll try to test this today |
Assuming you do not care to deal with a local Maven setup, the simplest way is to just use Plugin Manager » Advanced and install from the URL https://repo.jenkins-ci.org/incrementals/io/jenkins/docker/docker-plugin/1.6-rc1184.419d1ddd0e68/docker-plugin-1.6-rc1184.419d1ddd0e68.hpi (see the Incrementals check here). |
Thanks, way faster than waiting an hour for maven to download the internet. |
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.
BTW I confirmed that there is some effective test coverage insofar as DockerComputerJNLPConnectorTest
does fail if you e.g.
diff --git src/main/java/io/jenkins/docker/connector/DockerComputerJNLPConnector.java src/main/java/io/jenkins/docker/connector/DockerComputerJNLPConnector.java
index c94fcdb..de6dffc 100644
--- src/main/java/io/jenkins/docker/connector/DockerComputerJNLPConnector.java
+++ src/main/java/io/jenkins/docker/connector/DockerComputerJNLPConnector.java
@@ -181,7 +181,7 @@ public class DockerComputerJNLPConnector extends DockerComputerConnector {
final String configuredArgString = getEntryPointArgumentsString();
final String effectiveConfiguredArgString =
StringUtils.isNotBlank(configuredArgString) ? configuredArgString : DEFAULT_ENTRY_POINT_ARGUMENTS;
- final String resolvedArgString = Util.replaceMacro(effectiveConfiguredArgString, knownVariables);
+ final String resolvedArgString = Util.replaceMacro(effectiveConfiguredArgString, knownVariables) + " -xxx";
final String[] resolvedArgs = splitAndFilterEmpty(resolvedArgString, "\n");
cmd.withCmd(resolvedArgs);
@@ -62,7 +62,7 @@ | |||
<properties> | |||
<revision>1.6</revision> | |||
<changelist>-SNAPSHOT</changelist> | |||
<jenkins.version>2.414.3</jenkins.version> | |||
<jenkins.version>2.440</jenkins.version> |
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.
This (and the BOM line switch) are not exactly necessary and could be reverted, though I think it makes it clearer for purposes of tests and hpi:run
to run against the core versions which lack these fields in JNLPLauncher
and include an agent.jar
with the rewritten CLI options.
Is there anything we should add to the documentation before we review this PR? |
Tests that I performed to confirm the change is working as expected:
pipeline {
agent {
label 'alpine'
}
stages {
stage('Agent-Info') {
steps {
sh 'uname -a; cat /etc/os-release; java -version'
}
}
}
}
|
I've added c262ebb to document a generic form of the configuration that I tested. I verified that I see the null pointer exception without this change and that with this change the cloud operates as expected. |
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.
I think this is ready to merge and release.
DockerComputerJNLPConnector
templates: | ||
- connector: | ||
jnlp: | ||
jenkinsUrl: "https://jenkins.example.com/" |
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.
FWIW this is the part that gave me trouble during testing using a local Docker daemon: this URL needs to be accessible from the container, and if Jenkins is just running locally on the Docker host (as in mvn hpi:run
), there is not a standard way to make that happen.
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.
Thanks so much for the fix! I admit that I intentionally used two computers to perform the test so that the network had to be involved.
I had wanted to add agents running Alpine to my test environment but had not been willing to do the work to add them. The testing of this pull request has now provided me with agents running Alpine in my test environment. I still have a long way to go before those Alpine agents are as capable as my other agents, but it is nice to have started down the path.
Fixes #1047. Or so I suppose. I could not get an actual agent to connect but that is I guess an artifact of trying to run this plugin from
hpi:run
, since I do not have access to a system whereby the Jenkins controller would be accessible from containers:Not sure if moby/moby#40007 was supposed to fix this or what.