gocd-contrib / docker-elastic-agents-plugin

Docker-based elastic agents for GoCD
https://www.gocd.org
Apache License 2.0
31 stars 39 forks source link

IOException caught when processing request to {}->unix://localhost:80: Permission denied #40

Closed ccsalway closed 6 years ago

ccsalway commented 6 years ago

I have set up a docker container for gocd-server using alpine and pointed the docker.sock to the host which I've checked is showing in the server container. I've configured the plugin as instructed in the README, setup an agent config and assigned it to a job, but I still get the following error

2018-02-10 11:00:29,928 INFO  [qtp1952779858-28] MagicalGoConfigXmlWriter:85 - [Serializing Config] Generating config partial.
11:01:24.707 [140@MessageListener for ServerPingListener] DEBUG com.spotify.docker.client.DockerConfigReader - Using configfile: /home/go/.dockercfg 
Feb 10, 2018 11:01:24 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Permission denied
Feb 10, 2018 11:01:24 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
Feb 10, 2018 11:01:24 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Permission denied
Feb 10, 2018 11:01:24 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
Feb 10, 2018 11:01:24 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Permission denied
Feb 10, 2018 11:01:24 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
2018-02-10 11:01:24,916 ERROR [140@MessageListener for ServerPingListener] JMSMessageListenerAdapter:77 - Exception thrown in message handling by listener com.thoughtworks.go.server.messaging.elasticagents.ServerPingListener@43a3503d
java.lang.RuntimeException: Interaction with plugin with id 'cd.go.contrib.elastic-agent.docker' implementing 'elastic-agent' extension failed while requesting for 'go.cd.elastic-agent.server-ping'. Reason: [java.lang.RuntimeException: com.spotify.docker.client.exceptions.DockerException: java.util.concurrent.ExecutionException: javax.ws.rs.ProcessingException: java.io.IOException: Permission denied]
    at com.thoughtworks.go.plugin.access.PluginRequestHelper.submitRequest(PluginRequestHelper.java:57)
    at com.thoughtworks.go.plugin.access.elastic.ElasticAgentExtension.serverPing(ElasticAgentExtension.java:80)
    at com.thoughtworks.go.plugin.access.elastic.ElasticAgentPluginRegistry.serverPing(ElasticAgentPluginRegistry.java:50)
    at com.thoughtworks.go.server.messaging.elasticagents.ServerPingListener.onMessage(ServerPingListener.java:32)
    at com.thoughtworks.go.server.messaging.elasticagents.ServerPingListener.onMessage(ServerPingListener.java:22)
    at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.runImpl(JMSMessageListenerAdapter.java:73)
    at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.run(JMSMessageListenerAdapter.java:53)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.spotify.docker.client.exceptions.DockerException: java.util.concurrent.ExecutionException: javax.ws.rs.ProcessingException: java.io.IOException: Permission denied
    at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.executeActionOnTheService(FelixGoPluginOSGiFramework.java:318)
    at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.doOn(FelixGoPluginOSGiFramework.java:246)
    at com.thoughtworks.go.plugin.infra.DefaultPluginManager.submitTo(DefaultPluginManager.java:162)
    at com.thoughtworks.go.plugin.access.PluginRequestHelper.submitRequest(PluginRequestHelper.java:48)
    ... 7 common frames omitted
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.spotify.docker.client.exceptions.DockerException: java.util.concurrent.ExecutionException: javax.ws.rs.ProcessingException: java.io.IOException: Permission denied
    at cd.go.contrib.elasticagents.docker.DockerPlugin.handle(DockerPlugin.java:80)
    at com.thoughtworks.go.plugin.infra.DefaultPluginManager$2.execute(DefaultPluginManager.java:167)
    at com.thoughtworks.go.plugin.infra.DefaultPluginManager$2.execute(DefaultPluginManager.java:162)
    at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.executeActionOnTheService(FelixGoPluginOSGiFramework.java:316)
    ... 10 common frames omitted
Caused by: java.lang.RuntimeException: com.spotify.docker.client.exceptions.DockerException: java.util.concurrent.ExecutionException: javax.ws.rs.ProcessingException: java.io.IOException: Permission denied
    at cd.go.contrib.elasticagents.docker.DockerPlugin.refreshInstances(DockerPlugin.java:88)
    at cd.go.contrib.elasticagents.docker.DockerPlugin.handle(DockerPlugin.java:60)
    ... 13 common frames omitted
Caused by: com.spotify.docker.client.exceptions.DockerException: java.util.concurrent.ExecutionException: javax.ws.rs.ProcessingException: java.io.IOException: Permission denied
    at com.spotify.docker.client.DefaultDockerClient.propagate(DefaultDockerClient.java:2657)
    at com.spotify.docker.client.DefaultDockerClient.request(DefaultDockerClient.java:2588)
    at com.spotify.docker.client.DefaultDockerClient.ping(DefaultDockerClient.java:501)
    at cd.go.contrib.elasticagents.docker.DockerClientFactory.createClient(DockerClientFactory.java:68)
    at cd.go.contrib.elasticagents.docker.DockerClientFactory.docker(DockerClientFactory.java:46)
    at cd.go.contrib.elasticagents.docker.DockerContainers.docker(DockerContainers.java:133)
    at cd.go.contrib.elasticagents.docker.DockerContainers.refreshAll(DockerContainers.java:119)
    at cd.go.contrib.elasticagents.docker.DockerPlugin.refreshInstances(DockerPlugin.java:86)
    ... 14 common frames omitted
Caused by: java.util.concurrent.ExecutionException: javax.ws.rs.ProcessingException: java.io.IOException: Permission denied
    at jersey.repackaged.com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:299)
    at jersey.repackaged.com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:286)
    at jersey.repackaged.com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:116)
    at com.spotify.docker.client.DefaultDockerClient.request(DefaultDockerClient.java:2586)
    ... 20 common frames omitted
Caused by: javax.ws.rs.ProcessingException: java.io.IOException: Permission denied
    at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:481)
    at org.glassfish.jersey.apache.connector.ApacheConnector$1.run(ApacheConnector.java:491)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at jersey.repackaged.com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:299)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at jersey.repackaged.com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:50)
    at jersey.repackaged.com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:37)
    at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:487)
    at org.glassfish.jersey.client.ClientRuntime$2.run(ClientRuntime.java:178)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:340)
    at org.glassfish.jersey.client.ClientRuntime$3.run(ClientRuntime.java:210)
    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)
    ... 1 common frames omitted
Caused by: java.io.IOException: Permission denied
    at jnr.unixsocket.UnixSocketChannel.doConnect(UnixSocketChannel.java:94)
    at jnr.unixsocket.UnixSocketChannel.connect(UnixSocketChannel.java:102)
    at com.spotify.docker.client.ApacheUnixSocket.connect(ApacheUnixSocket.java:76)
    at com.spotify.docker.client.UnixConnectionSocketFactory.connectSocket(UnixConnectionSocketFactory.java:78)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
    at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:435)
    ... 21 common frames omitted
ketan commented 6 years ago
Caused by: java.io.IOException: Permission denied
    at jnr.unixsocket.UnixSocketChannel.doConnect(UnixSocketChannel.java:94)

Your docker socket needs to be writable by the go user inside the container, or whatever user is running the gocd server.

I'm marking this as closed, but if you think this is still an issue, please report back and someone can take a look.

ccsalway commented 6 years ago

I've tried your suggestion. Still the same.

screen shot 2018-02-12 at 10 15 42

Could it be something to do with docker.sock?

screen shot 2018-02-12 at 10 22 19

ketan commented 6 years ago

Yes, docker socket means the docker.sock file.

mykolasmolis commented 6 years ago

I gave read+write permission to /var/run/docker.sock file for go user and the plugin worked.