Merge "actions/ansible: catch errors when cleaning the work directory" into stable/train

This commit is contained in:
Zuul 2019-12-20 06:36:21 +00:00 committed by Gerrit Code Review
commit 8a8abd0378
1 changed files with 14 additions and 4 deletions

View File

@ -324,8 +324,13 @@ class AnsibleAction(actions.Action):
"log_path": os.path.join(self.work_dir, 'ansible.log')}
finally:
# NOTE(flaper87): clean the mess if debug is disabled.
if not self.verbosity and self._remove_work_dir:
shutil.rmtree(self.work_dir)
try:
if not self.verbosity and self._remove_work_dir:
shutil.rmtree(self.work_dir)
except Exception as e:
msg = "An error happened while cleaning work directory: " + e
LOG.error(msg)
return actions.Result(error=msg)
class AnsiblePlaybookAction(base.TripleOAction):
@ -663,8 +668,13 @@ class AnsiblePlaybookAction(base.TripleOAction):
"log_path": os.path.join(self.work_dir, 'ansible.log')}
finally:
# NOTE(flaper87): clean the mess if debug is disabled.
if not self.verbosity and self._remove_work_dir:
shutil.rmtree(self.work_dir)
try:
if not self.verbosity and self._remove_work_dir:
shutil.rmtree(self.work_dir)
except Exception as e:
msg = "An error happened while cleaning work directory: " + e
LOG.error(msg)
return actions.Result(error=msg)
class AnsibleGenerateInventoryAction(base.TripleOAction):