api_address value not compatible with docker client

Bug #1604812 reported by Ricardo Rocha
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Magnum
Fix Released
Undecided
Ricardo Rocha

Bug Description

Trying to pass the api_address value from a swarm bay to DOCKER_HOST fails.

# magnum bay-show cci-swarm-builder-02 |grep api_address
| api_address | https://137.138.6.236:2376

# export | grep DOCKER
declare -x DOCKER_CERT_PATH="."
declare -x DOCKER_HOST="https://137.138.6.236:2376"
declare -x DOCKER_TLS_VERIFY="True"

# docker info
Invalid bind address format: https://137.138.6.236:2376

Changing it to tcp (even with TLS enabled) works:

# export DOCKER_HOST=tcp://137.138.6.236:2376
# docker info
Containers: 4
 Running: 3
 Paused: 0
...

Probably the reason we don't see this in the tests is that the python docker client supports https properly, so this code works as expected:

import docker
from docker import client
from docker import tls

if __name__ == "__main__":
    client = client.Client(
            base_url='https://137.138.6.236:2376',
            version='1.21',
            timeout=2,
            tls=tls.TLSConfig(
                client_cert=('/home/ricardo/bays/cci-swarm-builder-02/cert.pem', '/home/ricardo/bays/cci-swarm-builder-02/key.pem'),
                verify='/home/ricardo/bays/cci-swarm-builder-02/ca.pem',
                assert_hostname=False
        ))

    print(client.containers(all=True))

The good news is that simply changing https to tcp does the trick, and the DOCKER_TLS_VERIFY (in cli) and the client.Client(tls=) option do the trick on enable/disable TLS.

description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to magnum (master)

Fix proposed to branch: master
Review: https://review.openstack.org/344835

Changed in magnum:
assignee: nobody → Ricardo Rocha (rocha-porto)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to magnum (master)

Reviewed: https://review.openstack.org/344835
Committed: https://git.openstack.org/cgit/openstack/magnum/commit/?id=9c093da9556f1d5e82ddb031250fb343dcdec1c4
Submitter: Jenkins
Branch: master

commit 9c093da9556f1d5e82ddb031250fb343dcdec1c4
Author: Ricardo Rocha <email address hidden>
Date: Wed Jul 20 15:19:46 2016 +0200

    Set swarm api_address protocol to tcp on all cases.

    The docker command line client does not allow https as protocol in the
    DOCKER_HOST string. Set protocol in the api_address field in the bay to
    tcp in all cases for compatibility (works also for TLS enabled bays).

    This is also compatible with the python docker client (docker-py).

    Change-Id: I7ef4e2d154c6ad682d4124f7a3adbfeef4e91e0c
    Closes-Bug: #1604812

Changed in magnum:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/magnum 3.0.0

This issue was fixed in the openstack/magnum 3.0.0 release.

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.