Bug 1890: Improve Action Execution 71/12471/2
authorMark Beierl <mark.beierl@canonical.com>
Fri, 19 Aug 2022 19:01:06 +0000 (15:01 -0400)
committercubag <gcuba@whitestack.com>
Mon, 22 Aug 2022 23:06:28 +0000 (01:06 +0200)
Changes exception handling to put the content of the exception
into the ns action result so failures have meaningful output

Change-Id: I361c4ed6b03012cd4432ba72215c99f9aaf45b55
Signed-off-by: Mark Beierl <mark.beierl@canonical.com>
osm_lcm/ns.py

index b1c027a..6cb46e1 100644 (file)
@@ -4990,9 +4990,7 @@ class NsLcm(LcmBase):
                     break
                 except asyncio.CancelledError:
                     raise
-                except Exception as e:  # asyncio.TimeoutError
-                    if isinstance(e, asyncio.TimeoutError):
-                        e = "Timeout"
+                except Exception as e:
                     retries -= 1
                     if retries >= 0:
                         self.logger.debug(
@@ -5003,7 +5001,9 @@ class NsLcm(LcmBase):
                         # wait and retry
                         await asyncio.sleep(retries_interval, loop=self.loop)
                     else:
-                        return "FAILED", str(e)
+                        if isinstance(e, asyncio.TimeoutError):
+                            e = N2VCException(message="Timed out waiting for action to complete")
+                        return "FAILED", getattr(e, 'message', repr(e))
 
             return "COMPLETED", output
 
@@ -5338,7 +5338,7 @@ class NsLcm(LcmBase):
             )
             self.logger.debug(
                 logging_text
-                + " task Done with result {} {}".format(
+                + "Done with result {} {}".format(
                     nslcmop_operation_state, detailed_status
                 )
             )