Docker Network port information are wrong

Bug #1297972 reported by Chmouel Boudjnah
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Expired
Undecided
Unassigned

Bug Description

Docker plugin assume things about docker networkinfo which does not seem to exist in my latest docker version, for example this is the info we are getting from docker python binding about networking :

stack@devstack:~$ ipython
iPython 2.7.5+ (default, Feb 27 2014, 19:37:08)
Type "copyright", "credits" or "license" for more information.

IPython 0.13.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: import docker

In [2]: c = docker.Client()

In [3]: c.inspect_
c.inspect_container c.inspect_image

In [3]: i = c.inspect_container("cc31f8b4e48f")

[...]

In [7]: i['NetworkSettings']
Out[7]:
{u'Bridge': u'docker0',
 u'Gateway': u'172.17.42.1',
 u'IPAddress': u'172.17.0.2',
 u'IPPrefixLen': 16,
 u'PortMapping': None,
 u'Ports': {u'3306/tcp': None}}

the Ports key is then coming back here:

 u'Ports': {u'3306/tcp': None}}

when the code assume this :
          https://github.com/openstack/heat/blob/master/contrib/docker/docker/resources/docker_container.py#L155
            if not info or len(p) != 2 or 'HostPort' not in info[0]:
                continue

which is nowhere to be seen in that dict and does not come back then with the ports.

A quick patch like that gets the ports properly listed :

diff --git i/contrib/docker/docker/resources/docker_container.py w/contrib/docker/docker/resources/docker_container.py
index 1b0fee8..cf67eba 100644
--- i/contrib/docker/docker/resources/docker_container.py
+++ w/contrib/docker/docker/resources/docker_container.py
@@ -153,9 +153,9 @@ class DockerContainer(resource.Resource):
         udp = []
         for port, info in networkinfo['Ports'].iteritems():
             p = port.split('/')
- if not info or len(p) != 2 or 'HostPort' not in info[0]:
+ if len(p) != 2:
                 continue
- port = info[0]['HostPort']
+ port = p[0]
             if p[1] == 'tcp':
                 tcp.append(port)
             elif p[1] == 'udp':

I am not submitting that just yet because i am not sure if i am just using it wrong and handle some other case I don't see about (from looking at the sourcecode of docker python binding)

let me know what do you think.

Revision history for this message
Thomas Herve (therve) wrote :

IIUC, the code in Heat is correct, as it only return *exposed* ports, which is what the HostPort value gives you. If it's None, I think it means it's not exposed.

Zane Bitter (zaneb)
Changed in heat:
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for heat because there has been no activity for 60 days.]

Changed in heat:
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.