jenkinsci / docker-swarm-plugin

Jenkins plugin which allows to add a Docker Swarm as a cloud agent provider
https://plugins.jenkins.io/docker-swarm/
MIT License
55 stars 47 forks source link

Version 1.11 On Jenkins 2.263.3 Agent Unable To Download JNLP File From Host #109

Open David-Villeneuve opened 3 years ago

David-Villeneuve commented 3 years ago

Upgraded from 1.9 to 1.11 and Agents no longer start. They get an error downloading the .jnlp file from jenkins:

[9:08:51 PM] Creating Service with Name : agt-e_Center_Upload-4 [9:08:51 PM] ServiceSpec created with ID : wxdymep26euwr7tqy6eo91667 [9:08:51 PM] ServiceSpec request JSON : {"TaskTemplate":{"ContainerSpec":{"Image":"docreg-builder.bts.rim.net/build_u16basebuild_mainline_container:latest","Command":["sh","-cx","curl --connect-timeout 20 --max-time 60 -o agent.jar $DOCKER_SWARM_PLUGIN_JENKINS_AGENT_JAR_URL && java -jar agent.jar -jnlpUrl $DOCKER_SWARM_PLUGIN_JENKINS_AGENT_JNLP_URL -secret $DOCKER_SWARM_PLUGIN_JENKINS_AGENT_SECRET -noReconnect -workDir /tmp"],"Env":["DOCKER_SWARM_PLUGIN_JENKINS_AGENT_SECRET=a120dbdfcff9f5eb63e8d01eb17f6b438ac17ebc80fb5a12a491a69f06eaa8a5","DOCKER_SWARM_PLUGIN_JENKINS_AGENT_JAR_URL=http://jenkins.example.comt:8080/jnlpJars/agent.jar","DOCKER_SWARM_PLUGIN_JENKINS_AGENT_JNLP_URL=http://jenkins.example.comt:8080/computer/agt-e_Center_Upload-4/jenkins-agent.jnlp","DOCKER_SWARM_PLUGIN_JENKINS_AGENT_NAME=agt-e_Center_Upload-4"],"Dir":"/builds","User":"builder","DNSConfig":{"Nameservers":[],"Search":[],"Options":[]},"Mounts":[{"Target":"/home/builder/.subversion","Source":"/home/builder/.subversion","Type":"bind","VolumeOptions":null},{"Target":"/home/builder/.qnx","Source":"/home/builder.qnx","Type":"bind","VolumeOptions":null},{"Target":"/home/builder/.ssh","Source":"/home/builder/.ssh","Type":"bind","VolumeOptions":null},{"Target":"/home/builder/.artifactory_python.cfg","Source":"/home/builder/.artifactory_python.cfg","Type":"bind","VolumeOptions":null}],"Hosts":["10.122.90.239 jenkins.example.com","10.222.4.15 svn.example.com svn"],"Secrets":[],"Configs":[]},"RestartPolicy":{"Condition":"none","MaxAttempts":0},"Resources":{"Limits":{"NanoCPUs":0,"MemoryBytes":0},"Reservations":{"NanoCPUs":0,"MemoryBytes":0}},"Placement":{"Constraints":[],"Platforms":[{"Architecture":"","OS":""}]}},"EndpointSpec":{"Ports":[]},"Name":"agt-e_Center_Upload-4","Labels":{"ROLE":"jenkins-agent"},"Networks":[]} k+ curl --connect-timeout 20 --max-time 60 -o agent.jar http://jenkins.example.com:8080/jnlpJars/agent.jar P % Total % Received % Xferd Average Speed Time Time Time Current N Dload Upload Total Spent Left Speed � 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 1485k 100 1485k 0 0 46.6M 0 --:--:-- --:--:-- --:--:-- 48.3M �+ java -jar agent.jar -jnlpUrl http://jenkins.example.comt:8080/computer/agt-e_Center_Upload-4/jenkins-agent.jnlp -secret a120dbdfcff9f5eb63e8d01eb17f6b438ac17ebc80fb5a12a491a69f06eaa8a5 -noReconnect -workDir /tmp WFeb 26, 2021 9:08:52 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir 7INFO: Using /tmp/remoting as a remoting work directory RFeb 26, 2021 9:08:52 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging BINFO: Both error and output logs will be printed to /tmp/remoting �Exception in thread "main" java.io.IOException: Failed to obtain http://jenkins.example.com:8080/computer/agt-e_Center_Upload-4/jenkins-agent.jnlp?encrypt=true C at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:577) 4 at hudson.remoting.Launcher.run(Launcher.java:347) 5 at hudson.remoting.Launcher.main(Launcher.java:298) �Caused by: java.io.IOException: Failed to load http://jenkins.example.com:8080/computer/agt-e_Center_Upload-4/jenkins-agent.jnlp?encrypt=true: 404 Not Found C at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:519)  ... 2 more

Host is Ubuntu 16, java is openjdk version "1.8.0_242" OpenJDK Runtime Environment (build 1.8.0_242-8u242-b08-0ubuntu3~16.04-b08) OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

pk1057 commented 3 years ago

I have the problem too, reverting to 1.9 and everything is fine.

java.runtime.version | 1.8.0_282-b08 java.vendor | AdoptOpenJDK Ubuntu 16

ghost commented 3 years ago

Same issue here with Docker Swarm 1.11 on Debian 9 with Jenkins 2.263.4 LTS with Java Corretto 8.282.08.1. Rolling back to Docker Swarm 1.9 fixes it.

�Exception in thread "main" java.io.IOException: Failing to obtain http://jenkins.rsvphost.internal/computer/agt-CI_Base_Ami_153-2/jenkins-agent.jnlp?encrypt=true C at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:555) 4 at hudson.remoting.Launcher.run(Launcher.java:322) 5 at hudson.remoting.Launcher.main(Launcher.java:283) �Caused by: java.io.IOException: Failed to load http://jenkins.rsvphost.internal/computer/agt-CI_Base_Ami_153-2/jenkins-agent.jnlp?encrypt=true: 403 Forbidden C at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:496)  ... 2 more

AStuntman commented 3 years ago

The problem is in https://github.com/jenkinsci/docker-swarm-plugin/blob/d6e0dc1fd4717dc178cf2ab81c8e7a5820fbf9fd/src/main/java/org/jenkinsci/plugins/docker/swarm/DockerSwarmComputerLauncher.java#L339 jnlp are renamed in jenkins from jenkins-agent.jnlp to slave-agent.jnlp

I think there are differents between Jenkins LTS and Jenkins. Jenkins LTS based on old code.

pk1057 commented 3 years ago

It seems that you need at least 2.277.2 due to the following change JENKINS-35452 So normally the minimal requirement for this build should be 2.277 and not 2.78

< DOCKER_SWARM_PLUGIN_JENKINS_AGENT_JAR_URL https://xxx.xxxx.de/jenkins/jnlpJars/agent.jar DOCKER_SWARM_PLUGIN_JENKINS_AGENT_JNLP_URL https://xxx.xxx.de/jenkins/computer/agt-OMM_vaadin_19_3-2/jenkins-agent.jnlp>

David-Villeneuve commented 3 years ago

I had no problem with 2.277.1 on my QA system, but it was still happening on my production system.

The problem turned out to be with the production system being behind a proxy (wrapped access in https and used a different hostname). The JNLP needed to connect to port 500002, but was trying the proxy server instead of the jenkins server (other Windows JNLP slaves were ok).

I worked around this by applying the following directive to jenkins on startup (replace myrealhost.sample.net with your actual real host name):

-Dhudson.TcpSlaveAgentListener.hostName=myrealhost.sample.net

After that, it worked.

rtayek commented 3 years ago

i get the same thing on windows pro 10.0.19042 Build 19042 with jenkins 2.277.4 and agent 4.6 and no docker or swarm.

java -jar lib/agent.jar -jnlpUrl http://localhost:8080/computer/agent-1/jenkins-agent.jnlp -secret ... -workDir "d:\jenkins-node-1"

failed as well as slave-agent.

rtayek commented 3 years ago

i get the same thing on windows pro 10.0.19042 Build 19042 with jenkins 2.277.4 and agent 4.6 and no docker or swarm.

java -jar lib/agent.jar -jnlpUrl http://localhost:8080/computer/agent-1/jenkins-agent.jnlp -secret ... -workDir "d:\jenkins-node-1"

failed as well as slave-agent.

duh! - that was because i was using the jenkins' secret instead of the one in front of my nose in the example on the agent screen.

shaishap commented 2 years ago

Same issue occurred for us. Reverting to 1.9 immediately resolved it. We are using LTS 2.235.5 docker, running on Ubuntu 16.04.4

tyumin commented 2 years ago

I solved this problem by replacing "jenkins-agent.jnlp" with "slave-agent.jnlp" before curl execution

DOCKER_SWARM_PLUGIN_JENKINS_AGENT_JNLP_URL="${DOCKER_SWARM_PLUGIN_JENKINS_AGENT_JNLP_URL//jenkins-agent.jnlp/slave-agent.jnlp}" && curl ...