From: Kefu Chai Date: Mon, 4 Mar 2019 16:46:24 +0000 (+0800) Subject: ansible.py: catch yaml.YAMLError when yaml.safe_load() X-Git-Tag: 1.1.0~267^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e26e58a77f4a89f7b838aacad801d04fc194f953;p=teuthology.git ansible.py: catch yaml.YAMLError when yaml.safe_load() yaml.safe_load() also throws yaml.scanner.ScannerError. so use yaml.YAMLError to cover them all. see https://pyyaml.org/wiki/PyYAMLDocumentation . Signed-off-by: Kefu Chai --- diff --git a/teuthology/task/ansible.py b/teuthology/task/ansible.py index dfc009feba..1b535e58dc 100644 --- a/teuthology/task/ansible.py +++ b/teuthology/task/ansible.py @@ -306,10 +306,10 @@ class Ansible(Task): with open(self.failure_log.name, 'r') as fail_log: try: failures = yaml.safe_load(fail_log) - except yaml.parser.ParserError: + except yaml.YAMLError as e: log.error( - "Failed to parse ansible failure log: {0}".format( - self.failure_log.name, + "Failed to parse ansible failure log: {0} ({1})".format( + self.failure_log.name, e ) ) failures = fail_log.read().replace('\n', '')