jenkinsci / docker-plugin

Jenkins cloud plugin that uses Docker
https://plugins.jenkins.io/docker-plugin/
MIT License
490 stars 318 forks source link

[JENKINS-72592] Fix inbound agent connector NPE on Jenkins 2.437+ #1049

Closed jglick closed 7 months ago

jglick commented 7 months ago

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:

java.io.IOException: Failed to connect to http://host.docker.internal:8080/jenkins/tcpSlaveAgentListener/: host.docker.internal
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:217)
    at hudson.remoting.Engine.innerRun(Engine.java:809)
    at hudson.remoting.Engine.run(Engine.java:563)
Caused by: java.net.UnknownHostException: host.docker.internal
    at java.base/sun.nio.ch.NioSocketImpl.connect(Unknown Source)
    at java.base/java.net.Socket.connect(Unknown Source)
    at java.base/sun.net.NetworkClient.doConnect(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.openServer(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.openServer(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.<init>(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.New(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.New(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:214)
    ... 2 more

Not sure if https://github.com/moby/moby/pull/40007 was supposed to fix this or what.

akomakom commented 7 months ago

I'll try to test this today

jglick commented 7 months ago

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).

akomakom commented 7 months ago

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.
Your branch is working fine in my quick test (Jenkins 2.444). :tada:

krisstern commented 7 months ago

Is there anything we should add to the documentation before we review this PR?

MarkEWaite commented 7 months ago

Tests that I performed to confirm the change is working as expected:

MarkEWaite commented 7 months ago
  • latest-alpine3.19-jdk21

I've added c262ebb99c509a328697887e2dbd68af038e0085 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.