]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: Fix logging of exceptions
authorSebastian Wagner <sebastian.wagner@suse.com>
Fri, 14 Feb 2020 14:32:55 +0000 (15:32 +0100)
committerSebastian Wagner <sebastian.wagner@suse.com>
Tue, 18 Feb 2020 12:08:00 +0000 (13:08 +0100)
`multiprocessing.pool.Pool#map_async` no longer has the exception
context, therefore calling `logging.exception` did not print the exception anymore.

Now, let's call `fail` while we have the exception context.

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/orchestrator/_interface.py

index a64d046315e4dea67a16bc1498fa09ab2b47c257..ca00adbeeb8d1e0f66fc757ecf639d4495d40887 100644 (file)
@@ -140,10 +140,15 @@ class AsyncCompletion(orchestrator.Completion):
                 self._on_complete_ = None
                 self._finalize(result)
             except Exception as e:
-                self.fail(e)
+                try:
+                    self.fail(e)
+                except Exception:
+                    logger.exception(f'failed to fail AsyncCompletion: >{repr(self)}<')
+                    if 'UNITTEST' in os.environ:
+                        assert False
 
         def error_callback(e):
-            self.fail(e)
+            pass
 
         def run(value):
             def do_work(*args, **kwargs):
@@ -155,11 +160,8 @@ class AsyncCompletion(orchestrator.Completion):
                         self.progress_reference.progress += 1.0 / len(value)
                     return res
                 except Exception as e:
-                    if six.PY3:
-                        raise
-                    else:
-                        # Py2 only: _worker_pool doesn't call error_callback
-                        self.fail(e)
+                    self.fail(e)
+                    raise
 
             assert CephadmOrchestrator.instance
             if self.many:
index 8901c4a9c1fb38bba93d3dc5151593e28f6293dc..ba5284b034b9b0356688da1f2699f81e226e07df 100644 (file)
@@ -385,7 +385,7 @@ class _Promise(object):
         assert self._state in (self.INITIALIZED, self.RUNNING)
         logger.exception('_Promise failed')
         self._exception = e
-        self._value = 'exception'
+        self._value = f'_exception: {e}'
         if self._next_promise:
             self._next_promise.fail(e)
         self._state = self.FINISHED