KostyaSha / yet-another-docker-plugin

Jenkins Yet Another Docker Plugin
https://plugins.jenkins.io/yet-another-docker-plugin
MIT License
83 stars 48 forks source link

Docker slave provisioning fails when using unix socket #107

Open ivantichy opened 7 years ago

ivantichy commented 7 years ago

I am using unix socket unix:///var/run/docker.sock as Docker URL. Test connection works OK. When I run a job then provisioning fails with:

Nov 01, 2016 2:39:44 PM com.github.kostyasha.yad.DockerCloud lambda$provision$0 SEVERE: Error in provisioning; template='DockerSlaveTemplate[id=45e5c85e-3bd3-46d8-b979-217947de8937,labelString=docker,launcher=com.github.kostyasha.yad.launcher.DockerComputerSSHLauncher@6a11257d,remoteFs=/home/jenkins,maxCapacity=1,mode=EXCLUSIVE,retentionStrategy=com.github.kostyasha.yad.strategy.DockerOnceRetentionStrategy@27f,numExecutors=1,dockerContainerLifecycle=com.github.kostyasha.yad.DockerContainerLifecycle@6e355eb2[image=ivantichy/chemaxon-build-slave,pullImage=com.github.kostyasha.yad.commons.DockerPullImage@b0ab6c18,createContainer=DockerCreateContainer[command=,hostname=,dnsHosts=[],volumes=[/root/chemaxongit:/root/chemaxongit],volumesFrom=[],environment=[],bindPorts=,bindAllPorts=true,memoryLimit=0,cpuShares=<null>,privileged=true,tty=false,macAddress=<null>,extraHosts=[],networkMode=<null>,devices=[],cpusetCpus=,cpusetMems=,links=[]],stopContainer=com.github.kostyasha.yad.commons.DockerStopContainer@27f,removeContainer=com.github.kostyasha.yad.commons.DockerRemoveContainer@5aea],nodeProperties=[]]' for cloud='Docker' java.lang.NullPointerException at com.github.kostyasha.yad_docker_java.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:212) at com.github.kostyasha.yad_docker_java.com.google.common.net.HostAndPort.fromString(HostAndPort.java:168) at com.github.kostyasha.yad_docker_java.com.google.common.net.HostAndPort.fromParts(HostAndPort.java:135) at com.github.kostyasha.yad.launcher.DockerComputerSSHLauncher.getHostAndPort(DockerComputerSSHLauncher.java:151) at com.github.kostyasha.yad.launcher.DockerComputerSSHLauncher.waitUp(DockerComputerSSHLauncher.java:83) at com.github.kostyasha.yad.DockerCloud.provisionWithWait(DockerCloud.java:219) at com.github.kostyasha.yad.DockerCloud.lambda$provision$0(DockerCloud.java:120) at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

There is no such problem when I use tcp.

ivantichy commented 7 years ago

Plugin version: 0.1.0-rc28
Jenkins ver: 2.19.1 Java: 1.8.0_111-b14 Oracle

ashiots2 commented 7 years ago

Same exact issue here as well using 0.1.0-rc29 and Oracle's 8u112

pporada-gl commented 7 years ago

Are you on Docker 1.12.x and do you have a systemd socket file in place? https://github.com/docker/docker/tree/master/contrib/init/systemd

pporada-gl commented 7 years ago

Disregard my previous comment. I am running into the same issue.

YADP 0.1.0-rc29
[root@365f17e65bac ~]# docker version
Client:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        
 OS/Arch:      linux/amd64
[root@365f17e65bac ~]# java -version 
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-b15)
OpenJDK 64-Bit Server VM (build 25.111-b15, mixed mode)
Nov 10, 2016 5:11:39 PM SEVERE com.github.kostyasha.yad.DockerCloud lambda$provision$0

Error in provisioning; template='DockerSlaveTemplate[id=3413aa87-f92e-43db-9d16-cf0d17aaa061,labelString=docker-slave,launcher=com.github.kostyasha.yad.launcher.DockerComputerSSHLauncher@461caf10,remoteFs=/home/jenkins,maxCapacity=10,mode=EXCLUSIVE,retentionStrategy=com.github.kostyasha.yad.strategy.DockerOnceRetentionStrategy@27f,numExecutors=1,dockerContainerLifecycle=com.github.kostyasha.yad.DockerContainerLifecycle@64c02363[image=greenlancer/jenkins-slave:latest,pullImage=com.github.kostyasha.yad.commons.DockerPullImage@1a93cb47,createContainer=DockerCreateContainer[command=/opt/entrypoint.sh,hostname=,dnsHosts=[],volumes=[/var/run/docker.sock:/var/run/docker.sock],volumesFrom=[],environment=[],bindPorts=,bindAllPorts=false,memoryLimit=1536,cpuShares=1024,privileged=false,tty=true,macAddress=<null>,extraHosts=[],networkMode=<null>,devices=[],cpusetCpus=,cpusetMems=,links=[]],stopContainer=com.github.kostyasha.yad.commons.DockerStopContainer@27f,removeContainer=com.github.kostyasha.yad.commons.DockerRemoveContainer@5b0f],nodeProperties=[]]' for cloud='Docker Slave'
java.lang.NullPointerException
    at com.github.kostyasha.yad_docker_java.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:212)
    at com.github.kostyasha.yad_docker_java.com.google.common.net.HostAndPort.fromString(HostAndPort.java:168)
    at com.github.kostyasha.yad_docker_java.com.google.common.net.HostAndPort.fromParts(HostAndPort.java:135)
    at com.github.kostyasha.yad.launcher.DockerComputerSSHLauncher.getHostAndPort(DockerComputerSSHLauncher.java:151)
    at com.github.kostyasha.yad.launcher.DockerComputerSSHLauncher.waitUp(DockerComputerSSHLauncher.java:83)
    at com.github.kostyasha.yad.DockerCloud.provisionWithWait(DockerCloud.java:219)
    at com.github.kostyasha.yad.DockerCloud.lambda$provision$0(DockerCloud.java:120)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
KostyaSha commented 7 years ago

So it can't extract host and port for ssh connection. Why not to use JNLP launcher?

pporada-gl commented 7 years ago

I was expecting this to work the same as the Docker Plugin where I had the SSH launcher working. However, that was on Docker 1.11.2 and the Docker Plugin failed to work after upgrading to Docker 1.12.3.

When using the JNLP launcher, I receive this

Nov 10, 2016 5:32:19 PM INFO com.github.kostyasha.yad.DockerCloud provision
Asked to provision load: '1', for: 'docker-slave' label

Nov 10, 2016 5:32:19 PM INFO com.github.kostyasha.yad.DockerCloud provision
Will provision 'greenlancer/jenkins-slave:latest', for label: 'docker-slave', in cloud: 'Docker Slave'

Nov 10, 2016 5:32:19 PM INFO com.github.kostyasha.yad.DockerCloud addProvisionedSlave
Not Provisioning 'greenlancer/jenkins-slave:latest'; Server 'Docker Slave' full with '5' container(s)
KostyaSha commented 7 years ago

Could you fill separate issue and post more logs? Also please try provide docker log for running/failing containers. (TODO add reporting automatically from plugin)

ivantichy commented 7 years ago

Why not to use JNLP launcher? Sorry to ask but why not to fix it rather?