Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix Deprecation warning from docker_py
Squashes : Passing host config parameters in start() is deprecated
  • Loading branch information
anish committed Mar 6, 2016
1 parent d521f15 commit 3c702fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion master/buildbot/test/fake/docker.py
Expand Up @@ -22,7 +22,7 @@ def __init__(self, base_url):
def images(self):
return self._images

def start(self, *args, **kwargs):
def start(self, container):
pass

def stop(self, id):
Expand All @@ -42,6 +42,9 @@ def build(self, fileobj, tag):
yield line
self._images.append({'RepoTags': [tag + ':latest']})

def create_host_config(self, *args, **kwargs):
pass

def create_container(self, image, *args, **kwargs):
return {'Id': '8a61192da2b3bb2d922875585e29b74ec0dc4e0117fcbf84c962204e97564cd7',
'Warnings': None}
9 changes: 6 additions & 3 deletions master/buildbot/worker/docker.py
Expand Up @@ -64,7 +64,7 @@ def __init__(self, name, password, docker_host, image=None, command=None,
**kwargs):

if not client:
config.error("The python module 'docker-py' is needed to use a"
config.error("The python module 'docker-py>=1.4' is needed to use a"
" DockerLatentWorker")
if not image and not dockerfile:
config.error("DockerLatentWorker: You need to specify at least"
Expand Down Expand Up @@ -156,12 +156,15 @@ def _thd_start_instance(self, image):
'Image "%s" not found on docker host.' % image
)

host_conf = docker_client.create_host_config(binds=self.binds)

instance = docker_client.create_container(
image,
self.command,
name='%s_%s' % (self.workername, id(self)),
volumes=self.volumes,
environment=self.createEnvironment()
environment=self.createEnvironment(),
host_config=host_conf
)

if instance.get('Id') is None:
Expand All @@ -173,7 +176,7 @@ def _thd_start_instance(self, image):
log.msg('Container created, Id: %s...' % (shortid,))
instance['image'] = image
self.instance = instance
docker_client.start(instance, binds=self.binds)
docker_client.start(instance)
log.msg('Container started')
if self.followStartupLogs:
logs = docker_client.attach(container=instance, stdout=True, stderr=True, stream=True)
Expand Down

0 comments on commit 3c702fc

Please sign in to comment.