Skip to content

Commit

Permalink
Support docker-py > 1.10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
anish committed Mar 27, 2017
1 parent 369ea01 commit b08a300
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions master/buildbot/test/fake/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ def create_container(self, image, *args, **kwargs):

def remove_container(self, id, **kwargs):
del self._containers[id]

class APIClient(Client):
pass
10 changes: 8 additions & 2 deletions master/buildbot/worker/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ def _image_exists(self, client, name):
return False

def _thd_start_instance(self, image, dockerfile, volumes):
docker_client = client.Client(**self.client_args)
if docker.version[0] == '1':
docker_client = client.Client(**self.client_args)
else:
docker_client = client.APIClient(**self.client_args)
# cleanup the old instances
instances = docker_client.containers(
all=1,
Expand Down Expand Up @@ -277,7 +280,10 @@ def stop_instance(self, fast=False):
return threads.deferToThread(self._thd_stop_instance, instance, fast)

def _thd_stop_instance(self, instance, fast):
docker_client = client.Client(**self.client_args)
if docker.version[0] == '1':
docker_client = client.Client(**self.client_args)
else:
docker_client = client.APIClient(**self.client_args)
log.msg('Stopping container %s...' % instance['Id'][:6])
docker_client.stop(instance['Id'])
if not fast:
Expand Down

0 comments on commit b08a300

Please sign in to comment.