Make kollda_docker works with new released python docker 3.0 package

the wait function in docker 3.0 return a dict now.

Closes-Bug: #1746748
Change-Id: Ice87128a936e36a0d7eb75c1ffd57dae39d89a64
This commit is contained in:
Jeffrey Zhang 2018-02-01 23:26:35 +08:00
parent 437d232dc4
commit d741eed94f
1 changed files with 5 additions and 1 deletions

View File

@ -635,11 +635,15 @@ class DockerWorker(object):
# We do not want to detach so we wait around for container to exit
if not self.params.get('detach'):
rc = self.dc.wait(self.params.get('name'))
# NOTE(jeffrey4l): since python docker package 3.0, wait return a
# dict all the time.
if isinstance(rc, dict):
rc = rc['StatusCode']
if rc != 0:
self.module.fail_json(
failed=True,
changed=True,
msg="Container exited with non-zero return code"
msg="Container exited with non-zero return code %s" % rc
)
if self.params.get('remove_on_exit'):
self.stop_container()