Log tracebacks

Always log the traceback for unexpected exceptions. It's very difficult
to tell where the error came from without the traceback.

It seems this was the intent with
Iad9de7fab0ee740bd20f8facd49f36e6f18d2fb1, but
traceback.format_exception doesn't actually print/log anything, it
returns a list of strings, which are just lost if not actually
saved/logged.

Instead use traceback.print_exc in the main handler to show the
traceback.

Change-Id: If84a41907e1fc782bd5a4608f445e75aa3a5d2fb
This commit is contained in:
James Slagle 2018-07-20 11:58:36 -04:00 committed by Evilien Macchi
parent d077cb33d8
commit 1034d65378
2 changed files with 2 additions and 3 deletions

View File

@ -13,8 +13,6 @@
# under the License.
#
import sys
import traceback
"""Exception definitions"""
@ -38,7 +36,6 @@ class NotFound(Exception):
class DeploymentError(RuntimeError):
"""Deployment failed"""
def __init__(self, *args, **kwargs):
traceback.format_exception(*sys.exc_info())
super(RuntimeError, self).__init__(*args, **kwargs)

View File

@ -27,6 +27,7 @@ import subprocess
import sys
import tarfile
import tempfile
import traceback
import yaml
from cliff import command
@ -1120,6 +1121,7 @@ class Deploy(command.Command):
rc = self._launch_ansible_deploy(self.ansible_dir)
except Exception as e:
self.log.error("Exception: %s" % six.text_type(e))
self.log.error(traceback.print_exc())
raise exceptions.DeploymentError(six.text_type(e))
finally:
if not parsed_args.keep_running: