I'm running into a strange issue using the standard docker images provided by Jenkins - only when Jenkins is running on Amazon Linux 2 though. Jenkins on Ubuntu 18.04 works fine.
The problem is that Jenkins is not able to launch these slave containers.
Connect method - "Attach Docker Container" since the docker engine is running locally on the Jenkins server.
Interestingly, I've been able to get these containers to successfully run for a build on Amazon Linux if I set USER root
in a new DockerFile (not required on Ubuntu). However, I need these to be running as a non-root user (like jenkins user) in order to run unit testing for postgres.
Any thoughts on how I can achieve that for Amazon Linux 2? Could I be missing a docker setting or security setting on the OS?
Connecting to docker container 4486c8f2696f40c7de32160d78d6e2438abb1ff92517c71cf66b93baf3d0877f, running command java -jar /home/jenkins/remoting-4.6.jar -noReconnect -noKeepAlive -slaveLog /home/jenkins/agent.log HTTP/1.1 101 UPGRADED Content-Type: application/vnd.docker.raw-stream Connection: Upgrade Upgrade: tcp Api-Version: 1.40 Docker-Experimental: false Ostype: linux Server: Docker/19.03.13-ce (Linux)
ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
Getting the same error since a few days.
We run a dockerized Jenkins with a Docker Cloud on a remote Server. Jenkins launches the contains on the remote server, but then fails with:
Connecting to docker container 32cc538f4287d7aaf11952b6cdcf619d92eb054d7d265ea72a3d7a6bdd1cf8d5, running command java -jar /home/jenkins/remoting-4.6.jar -noReconnect -noKeepAlive -slaveLog /home/jenkins/agent.log
HTTP/1.1 101 UPGRADED
Content-Type: application/vnd.docker.raw-stream
Connection: Upgrade
Upgrade: tcp
Api-Version: 1.40
Docker-Experimental: false
Ostype: linux
Server: Docker/19.03.13 (linux)
ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
Also: java.lang.Throwable: launched here
at hudson.slaves.SlaveComputer._connect(SlaveComputer.java:283)
at hudson.model.Computer.connect(Computer.java:435)
at com.nirima.jenkins.plugins.docker.strategy.DockerOnceRetentionStrategy.start(DockerOnceRetentionStrategy.java:80)
at com.nirima.jenkins.plugins.docker.strategy.DockerOnceRetentionStrategy.start(DockerOnceRetentionStrategy.java:35)
at hudson.model.AbstractCIBase.updateComputer(AbstractCIBase.java:162)
at hudson.model.AbstractCIBase.access$000(AbstractCIBase.java:44)
at hudson.model.AbstractCIBase$2.run(AbstractCIBase.java:224)
at hudson.model.Queue._withLock(Queue.java:1401)
at hudson.model.Queue.withLock(Queue.java:1278)
at hudson.model.AbstractCIBase.updateComputerList(AbstractCIBase.java:207)
at jenkins.model.Jenkins.updateComputerList(Jenkins.java:1632)
at jenkins.model.Nodes$2.run(Nodes.java:139)
at hudson.model.Queue._withLock(Queue.java:1401)
at hudson.model.Queue.withLock(Queue.java:1278)
at jenkins.model.Nodes.addNode(Nodes.java:135)
at jenkins.model.Jenkins.addNode(Jenkins.java:2155)
at com.nirima.jenkins.plugins.docker.DockerCloud.robustlyAddNodeToJenkins(DockerCloud.java:445)
at com.nirima.jenkins.plugins.docker.DockerCloud.access$000(DockerCloud.java:68)
at com.nirima.jenkins.plugins.docker.DockerCloud$1.run(DockerCloud.java:381)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
java.io.EOFException: unexpected stream termination
at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:415)
at hudson.remoting.ChannelBuilder.build(ChannelBuilder.java:360)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:425)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:392)
at io.jenkins.docker.connector.DockerComputerAttachConnector$DockerAttachLauncher.launch(DockerComputerAttachConnector.java:319)
at hudson.slaves.DelegatingComputerLauncher.launch(DelegatingComputerLauncher.java:64)
at io.jenkins.docker.connector.DockerDelegatingComputerLauncher.launch(DockerDelegatingComputerLauncher.java:37)
at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:294)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:80)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
I have faced this error today.
The problem is this command:
${JAVA_EXE}
${JVM_ARGS}
-jar
${FS_DIR}/${JAR_NAME}
-noReconnect
-noKeepAlive
-slaveLog
${FS_DIR}/agent.log
This is the command executed by Jenkins master to control the node. The problem is slaveLog parameter, Is agentLog now. I discovery it in this Jenkins issue thread ( Remote.jar is not working anymore because of changed parameter slave.jar->agent.jar ).
You can workaround this defining the Entrypoint CMD in the Docker Template configuration and changing the wrong parameter:
${JAVA_EXE}
${JVM_ARGS}
-jar
${FS_DIR}/${JAR_NAME}
-noReconnect
-noKeepAlive
-agentLog
${FS_DIR}/agent.log
After this, Jenkins can manage the node. Let me know if works for you too.
Happy Building .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.