From 4de5b04ab0f337233fb1593829e18216b726d17b Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Sun, 25 Mar 2018 23:53:18 -0700 Subject: task: don't hide exceptions in Task If the Task raised an exception we currently hide it and replace it with RuntimeError. This is bad. If an exception occured, then we don't have a result so re-raise the original exception. Or we could log the traceback and raise RuntimeError, but that doesn't seem to be a good idea. Sample traceback after re-raising original. Without this patch the ValueError is only written to _write_error_data 2018-03-25 22:57:56,511 yardstick.benchmark.contexts.node node.py:85 DEBUG BareMetals: [] 2018-03-25 22:57:56,511 yardstick.benchmark.contexts.node node.py:89 DEBUG Env: {} 2018-03-25 22:57:56,511 yardstick.cmd.commands.task task.py:57 INFO Task FAILED Traceback (most recent call last): File "/home/rbbratta/yardstick-upstream/yardstick/yardstick/cmd/commands/task.py", line 54, in do_start result = Task().start(param, **kwargs) File "/home/rbbratta/yardstick-upstream/yardstick/yardstick/benchmark/core/task.py", line 103, in start task_args_fnames) File "/home/rbbratta/yardstick-upstream/yardstick/yardstick/benchmark/core/task.py", line 321, in _parse_tasks task_args_fnames[i] File "/home/rbbratta/yardstick-upstream/yardstick/yardstick/benchmark/core/task.py", line 558, in parse_task context.init(cfg_attrs) File "/home/rbbratta/yardstick-upstream/yardstick/yardstick/benchmark/contexts/heat.py", line 131, in init server = Server(name, self, server_attrs) File "/home/rbbratta/yardstick-upstream/yardstick/yardstick/benchmark/contexts/model.py", line 210, in __init__ (name, p)) ValueError: server 'trafficgen_1', placement 'pgrp2' is invalid 2018-03-25 22:57:56,512 yardstick.cmd.commands.task task.py:62 INFO Task FAILED 2018-03-25 22:57:56,662 yardstick.benchmark.runners.base base.py:124 DEBUG Terminating all runners NoneType JIRA: YARDSTICK-1102 Change-Id: I7e6fa41fc1d36f6d438a1602ab60cb41ffbee1e9 Signed-off-by: Ross Brattain --- yardstick/cmd/commands/task.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py index a3488a23d..c6379e586 100644 --- a/yardstick/cmd/commands/task.py +++ b/yardstick/cmd/commands/task.py @@ -25,6 +25,7 @@ class TaskCommands(object): # pragma: no cover Set of commands to manage benchmark tasks. """ + EXIT_TEST_FAILED = 2 @cliargs("inputfile", type=str, help="path to task or suite file", nargs=1) @cliargs("--task-args", dest="task_args", @@ -48,18 +49,20 @@ class TaskCommands(object): # pragma: no cover param = change_osloobj_to_paras(args) self.output_file = param.output_file - result = {} LOG.info('Task START') try: result = Task().start(param, **kwargs) except Exception as e: # pylint: disable=broad-except self._write_error_data(e) - - if result.get('result', {}).get('criteria') == 'PASS': - LOG.info('Task SUCCESS') - else: LOG.info('Task FAILED') - raise RuntimeError('Task Failed') + raise + else: + if result.get('result', {}).get('criteria') == 'PASS': + LOG.info('Task SUCCESS') + else: + LOG.info('Task FAILED') + # exit without backtrace + raise SystemExit(self.EXIT_TEST_FAILED) def _write_error_data(self, error): data = {'status': 2, 'result': str(error)} -- cgit 1.2.3-korg