Merge branch '15694-cwl-hang' closes #15694
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 11 Oct 2019 18:54:44 +0000 (14:54 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 11 Oct 2019 18:54:44 +0000 (14:54 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

sdk/cwl/arvados_cwl/executor.py
sdk/cwl/tests/test_container.py

index eed2fe19df6a3f78a4a1f0ee40d26ccbf50f3349..406ebfd2da064df383105b8e0a7c8f4e7b19a529 100644 (file)
@@ -250,7 +250,11 @@ The 'jobs' API is no longer supported.
         activity statuses, for example in the RuntimeStatusLoggingHandler.
         """
         with self.workflow_eval_lock:
-            current = arvados_cwl.util.get_current_container(self.api, self.num_retries, logger)
+            current = None
+            try:
+                current = arvados_cwl.util.get_current_container(self.api, self.num_retries, logger)
+            except Exception as e:
+                logger.info("Couldn't get current container: %s", e)
             if current is None:
                 return
             runtime_status = current.get('runtime_status', {})
index 3374e1c13f8004100c2f3c114edbfba2db26dec6..cb6cfbadbdb00dcfe56872683b5851017eeb0f8f 100644 (file)
@@ -534,6 +534,25 @@ class TestContainer(unittest.TestCase):
         except RuntimeError:
             self.fail("RuntimeStatusLoggingHandler should not be called recursively")
 
+
+    # Test to make sure that an exception raised from
+    # get_current_container doesn't cause the logger to raise an
+    # exception
+    @mock.patch("arvados_cwl.util.get_current_container")
+    def test_runtime_status_get_current_container_exception(self, gcc_mock):
+        self.setup_and_test_container_executor_and_logging(gcc_mock)
+        root_logger = logging.getLogger('')
+
+        # get_current_container is invoked when we call
+        # runtime_status_update, it is going to also raise an
+        # exception.
+        gcc_mock.side_effect = Exception("Second Error")
+        try:
+            root_logger.error("First Error")
+        except Exception:
+            self.fail("Exception in logger should not propagate")
+        self.assertTrue(gcc_mock.called)
+
     @mock.patch("arvados_cwl.ArvCwlExecutor.runtime_status_update")
     @mock.patch("arvados_cwl.util.get_current_container")
     @mock.patch("arvados.collection.CollectionReader")