Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.8] fix erroneous failures in docker_compose due to deprecation warnings … #61971

Merged
merged 1 commit into from Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,2 @@
bugfixes:
- "docker_compose - fix issue where docker deprecation warning results in ansible erroneously reporting a failure"
44 changes: 36 additions & 8 deletions lib/ansible/modules/cloud/docker/docker_compose.py
Expand Up @@ -886,11 +886,18 @@ def cmd_pull(self):
except Exception as exc:
self.client.fail("Error: service image lookup failed - %s" % str(exc))

out_redir_name, err_redir_name = make_redirection_tempfiles()
# pull the image
try:
service.pull(ignore_pull_failures=False)
with stdout_redirector(out_redir_name):
with stderr_redirector(err_redir_name):
service.pull(ignore_pull_failures=False)
except Exception as exc:
self.client.fail("Error: pull failed with %s" % str(exc))
fail_reason = get_failure_info(exc, out_redir_name, err_redir_name,
msg_format="Error: pull failed with %s")
self.client.fail(**fail_reason)
else:
cleanup_redirection_tempfiles(out_redir_name, err_redir_name)

# store the new image ID
new_image_id = ''
Expand Down Expand Up @@ -933,11 +940,18 @@ def cmd_build(self):
except Exception as exc:
self.client.fail("Error: service image lookup failed - %s" % str(exc))

out_redir_name, err_redir_name = make_redirection_tempfiles()
# build the image
try:
new_image_id = service.build(pull=self.pull, no_cache=self.nocache)
with stdout_redirector(out_redir_name):
with stderr_redirector(err_redir_name):
new_image_id = service.build(pull=self.pull, no_cache=self.nocache)
except Exception as exc:
self.client.fail("Error: build failed with %s" % str(exc))
fail_reason = get_failure_info(exc, out_redir_name, err_redir_name,
msg_format="Error: build failed with %s")
self.client.fail(**fail_reason)
else:
cleanup_redirection_tempfiles(out_redir_name, err_redir_name)

if new_image_id not in old_image_id:
# if a new image was built
Expand Down Expand Up @@ -966,10 +980,17 @@ def cmd_down(self):
))
if not self.check_mode and result['changed']:
image_type = image_type_from_opt('--rmi', self.remove_images)
out_redir_name, err_redir_name = make_redirection_tempfiles()
try:
self.project.down(image_type, self.remove_volumes, self.remove_orphans)
with stdout_redirector(out_redir_name):
with stderr_redirector(err_redir_name):
self.project.down(image_type, self.remove_volumes, self.remove_orphans)
except Exception as exc:
self.client.fail("Error stopping project - %s" % str(exc))
fail_reason = get_failure_info(exc, out_redir_name, err_redir_name,
msg_format="Error stopping project - %s")
self.client.fail(**fail_reason)
else:
cleanup_redirection_tempfiles(out_redir_name, err_redir_name)
return result

def cmd_stop(self, service_names):
Expand Down Expand Up @@ -1057,10 +1078,17 @@ def cmd_scale(self):
result['changed'] = True
service_res['scale'] = scale - len(containers)
if not self.check_mode:
out_redir_name, err_redir_name = make_redirection_tempfiles()
try:
service.scale(scale)
with stdout_redirector(out_redir_name):
with stderr_redirector(err_redir_name):
service.scale(scale)
except Exception as exc:
self.client.fail("Error scaling %s - %s" % (service.name, str(exc)))
fail_reason = get_failure_info(exc, out_redir_name, err_redir_name,
msg_format="Error scaling {0} - %s".format(service.name))
self.client.fail(**fail_reason)
else:
cleanup_redirection_tempfiles(out_redir_name, err_redir_name)
result['actions'].append(service_res)
return result

Expand Down