[NFVBENCH-76] REST API remains in running state in case of exception 39/54439/1
authorahothan <ahothan@cisco.com>
Sun, 25 Mar 2018 00:09:36 +0000 (17:09 -0700)
committerahothan <ahothan@cisco.com>
Sun, 25 Mar 2018 00:11:25 +0000 (17:11 -0700)
catch the exception if result key is missing

Change-Id: Id212497bb760b835b542afd11ffbe149bc3d46e7
Signed-off-by: ahothan <ahothan@cisco.com>
nfvbench/nfvbenchd.py

index 76906c5..fa781af 100644 (file)
@@ -226,7 +226,7 @@ class WebSocketIoServer(object):
             # print 'main thread waiting for requests...'
             config = Ctx.dequeue()
             # print 'main thread processing request...'
-            print config
+            print config
             try:
                 # remove unfilled values as we do not want them to override default values with None
                 config = {k: v for k, v in config.items() if v is not None}
@@ -243,8 +243,15 @@ class WebSocketIoServer(object):
             else:
                 # this might overwrite a previously unfetched result
                 Ctx.set_result(results)
-            summary = NFVBenchSummarizer(results['result'], self.fluent_logger)
-            LOG.info(str(summary))
+            try:
+                summary = NFVBenchSummarizer(results['result'], self.fluent_logger)
+                LOG.info(str(summary))
+            except KeyError:
+                # in case of error, 'result' might be missing
+                if 'error_message' in results:
+                    LOG.error(results['error_message'])
+                else:
+                    LOG.error('REST request completed without results or error message')
             Ctx.release()
             if self.fluent_logger:
                 self.fluent_logger.send_run_summary(True)