diff --git a/glance/async_/taskflow_executor.py b/glance/async_/taskflow_executor.py index 867986a358..e8adbcc305 100644 --- a/glance/async_/taskflow_executor.py +++ b/glance/async_/taskflow_executor.py @@ -139,6 +139,9 @@ class TaskExecutor(glance.async_.TaskExecutor): raise exception.ImportTaskError(message=exc.msg) except RuntimeError: raise NotImplementedError() + except Exception as e: + LOG.exception(_LE('Task initialization failed: %s'), str(e)) + raise def begin_processing(self, task_id): try: diff --git a/glance/tests/unit/async_/test_taskflow_executor.py b/glance/tests/unit/async_/test_taskflow_executor.py index eb337e7d6f..ef01e8d63d 100644 --- a/glance/tests/unit/async_/test_taskflow_executor.py +++ b/glance/tests/unit/async_/test_taskflow_executor.py @@ -143,3 +143,15 @@ class TestTaskExecutor(test_utils.BaseTestCase): 'backend': None, 'admin_repo': admin_repo, 'uri': 'http://cloud.foo/image.qcow2'}) + + @mock.patch('stevedore.driver.DriverManager') + @mock.patch.object(taskflow_executor, 'LOG') + def test_get_flow_fails(self, mock_log, mock_driver): + mock_driver.side_effect = IndexError('fail') + executor = taskflow_executor.TaskExecutor(self.context, + self.task_repo, + self.image_repo, + self.image_factory) + self.assertRaises(IndexError, executor._get_flow, self.task) + mock_log.exception.assert_called_once_with( + 'Task initialization failed: %s', 'fail')