binocarlos / powerstrip-weave

A Powerstrip plugin that runs weave inside a container and ensures that containers are connected to the weave network before running their entrypoints.
36 stars 3 forks source link

Getting the adapter to trigger #4

Closed binocarlos closed 9 years ago

binocarlos commented 9 years ago

I'm having some trouble getting an adapter to be triggered from the powerstrip container.

Would love some help working out what I'm doing wrong or what the issue is as powerstrip-weave is now very close to done :-)

Here are the steps to replicate what is happening:

1. build the powerstrip container

this is from the 46d6a0eb79583e1e78e3ab0d8d0cf6102f47fe5b commit of the socket-support-protocol-tweaks-and-versioning branch

$ docker build -t clusterhq/powerstrip .
2. start a debug webserver

This is the simplest HTTP server that writes the request url to stdout.

var http = require('http')
var server = http.createServer(function(req, res){
  console.log('-------------------------------------------');
  console.log('req: ' + req.url)
})
server.listen(80, function(){
  console.log('server listening on port: 80')
})

This is listening not in a container but on my host (which is 192.168.8.120)

$ sudo node simpleserver.js

I run this in a seperate shell so can see what it logs.

3. create ~/powerstrip-demo/adapters.yml

The config will point at the debug web server running above on 192.168.8.120 - I've checked this IP is accesible from inside containers.

$ cat > ~/powerstrip-demo/adapters.yml <<EOF
version: 1
endpoints:
  "POST /*/containers/create":
    pre: [debug]
  "POST /*/containers/*/start":
    post: [debug]
adapters:
  debug: http://192.168.8.120/extension
EOF
4. start the powerstrip container
$ docker run -ti --rm --name powerstrip \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v ~/powerstrip-demo/adapters.yml:/etc/powerstrip/adapters.yml \
  -p 2375:2375 \
  clusterhq/powerstrip

I run this in attached mode in another seperate shell so can see what it logs.

5. change DOCKER_HOST
$ export DOCKER_HOST=localhost:2375
6. check docker ps works
$ docker ps -a

I get back results and see the powerstrip container logging - this works great.

7. docker run

This is where I cannot for the life of me get the adapter to trigger i.e. there is no output from the simple webserver where I would expect /v1.16/containers/create

$ docker run ubuntu echo hello

The full log from the powerstrip container is below - it is getting the requests for the following sequence (as expected):

However - the adapter itself (which should be printing these urls or at least the first one) never triggers.

Sorry if this is something dumb I'm doing - I've being racking my brains for the past few hours!

export DOCKER_HOST=tcp://localhost:2375
2015-01-22 01:47:49+0000 [-] Log opened.
2015-01-22 01:47:49+0000 [-] twistd 14.0.0 (/usr/bin/python 2.7.6) starting up.
2015-01-22 01:47:49+0000 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2015-01-22 01:47:49+0000 [-] ServerProtocolFactory starting on 2375
2015-01-22 01:47:49+0000 [-] Starting factory <powerstrip.powerstrip.ServerProtocolFactory instance at 0x7fefae119098>
2015-01-22 01:48:05+0000 [HTTPChannel,0,172.17.42.1] Starting factory <powerstrip.powerstrip.DockerProxyClientFactory instance at 0x7fefac046830>
2015-01-22 01:48:05+0000 [DockerProxyClient,client] "172.17.42.1" - - [22/Jan/2015:01:48:05 +0000] "GET /v1.16/containers/json?all=1 HTTP/1.1" 200 300 "-" "Docker-Client/1.4.1"
2015-01-22 01:48:05+0000 [DockerProxyClient,client] Stopping factory <powerstrip.powerstrip.DockerProxyClientFactory instance at 0x7fefac046830>
2015-01-22 01:48:30+0000 [HTTPChannel,1,172.17.42.1] Starting factory <powerstrip.powerstrip.DockerProxyClientFactory instance at 0x7fefac062a70>
2015-01-22 01:48:30+0000 [DockerProxyClient,client] "172.17.42.1" - - [22/Jan/2015:01:48:30 +0000] "POST /v1.16/containers/create HTTP/1.1" 201 90 "-" "Docker-Client/1.4.1"
2015-01-22 01:48:30+0000 [DockerProxyClient,client] Stopping factory <powerstrip.powerstrip.DockerProxyClientFactory instance at 0x7fefac062a70>
2015-01-22 01:48:30+0000 [HTTPChannel,2,172.17.42.1] Starting factory <powerstrip.powerstrip.DockerProxyClientFactory instance at 0x7fefabdef518>
2015-01-22 01:48:30+0000 [HTTPChannel,1,172.17.42.1] Starting factory <powerstrip.powerstrip.DockerProxyClientFactory instance at 0x7fefac035d40>
2015-01-22 01:48:31+0000 [DockerProxyClient,client] "172.17.42.1" - - [22/Jan/2015:01:48:30 +0000] "POST /v1.16/containers/33bd32dba637d4fb0ea21658426ce01ccf4bc0ee0f3eb08942ca2254464422d3/start HTTP/1.1" 204 - "-" "Docker-Client/1.4.1"
2015-01-22 01:48:31+0000 [DockerProxyClient,client] Stopping factory <powerstrip.powerstrip.DockerProxyClientFactory instance at 0x7fefac035d40>
2015-01-22 01:48:31+0000 [HTTPChannel,1,172.17.42.1] Starting factory <powerstrip.powerstrip.DockerProxyClientFactory instance at 0x7fefabdefdd0>
2015-01-22 01:48:31+0000 [DockerProxyClient,client] Stopping factory <powerstrip.powerstrip.DockerProxyClientFactory instance at 0x7fefabdef518>
2015-01-22 01:48:31+0000 [DockerProxyClient,client] "172.17.42.1" - - [22/Jan/2015:01:48:30 +0000] "POST /v1.16/containers/33bd32dba637d4fb0ea21658426ce01ccf4bc0ee0f3eb08942ca2254464422d3/wait HTTP/1.1" 200 17 "-" "Docker-Client/1.4.1"
2015-01-22 01:48:31+0000 [DockerProxyClient,client] Stopping factory <powerstrip.powerstrip.DockerProxyClientFactory instance at 0x7fefabdefdd0>
lukemarsden commented 9 years ago

Any chance you're running a version of a powerstrip Dockerfile before the plugins => adapters name change? If so, it will be looking for a config in /etc/powerstrip/plugins.yml, but you'll have put it in /etc/powerstrip/adapters.yml. This definitely need some usability improvements, such as bailing out if it can't find a config file. I opened https://github.com/ClusterHQ/powerstrip/issues/30 and https://github.com/ClusterHQ/powerstrip/issues/31 to help with this.

lukemarsden commented 9 years ago

Turns out this was fixed by https://github.com/ClusterHQ/powerstrip/commit/b44c887064d46b5b4453652de41351b09b5c66ec !