Skip to content

Commit

Permalink
[CE-41] Swarm detection for latest docker version
Browse files Browse the repository at this point in the history
In the newest versions of docker, swarm is included and the server
version field of docker info does not return any "swarm" addition.
To detect a swarm active machine,I'm proposing to check swarm.cluster.ID
this field is empty for non swarm and contains a string of hexa when
swarm is configured

The change affects src/agent/docker/dockr_swarm.py and consist of
capturing the swarm.cluster.ID and to take that into account as an
alternative swarm detection mechanism
        server_swarm_cluster = client.info()['Swarm']['Cluster']['ID']
        if server_version.startswith('swarm') or server_swarm_cluster != '':

To test, cello was activated with some additional logging.debug
(removed from the release file) in the setup_container_host to show the
creating was happening on swarm machine. Testing was performed on Ubuntu
 server and on Centos (with fix CE-49)

Issue: CE-41
Change-Id: I01c627cdfd142d771a25cd427ef29fe1c9347dc3
Signed-off-by: Daniel Vielvoye <[email protected]>
  • Loading branch information
aemlin committed May 22, 2017
1 parent 67f6a3e commit f2fd343
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/agent/docker/docker_swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def detect_daemon_type(daemon_url, timeout=5):
try:
client = Client(base_url=daemon_url, version="auto", timeout=timeout)
server_version = client.info()['ServerVersion']
if server_version.startswith('swarm'):
server_swarm_cluster = client.info()['Swarm']['Cluster']['ID']
if server_version.startswith('swarm') or server_swarm_cluster != '':
return HOST_TYPES[1]
else:
return HOST_TYPES[0]
Expand Down

0 comments on commit f2fd343

Please sign in to comment.