]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
ansible.py: catch yaml.YAMLError when yaml.safe_load() 1264/head
authorKefu Chai <kchai@redhat.com>
Mon, 4 Mar 2019 16:46:24 +0000 (00:46 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 4 Mar 2019 16:51:25 +0000 (00:51 +0800)
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 <kchai@redhat.com>
teuthology/task/ansible.py

index dfc009feba40257e03674bf3b5009a49667da82d..1b535e58dc6882e7645d44ecd27a4c8dfa455779 100644 (file)
@@ -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', '')