]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator: don't have _select_orchestrator raise exceptions
authorJeff Layton <jlayton@redhat.com>
Tue, 12 Feb 2019 12:16:06 +0000 (07:16 -0500)
committerJeff Layton <jlayton@redhat.com>
Tue, 12 Feb 2019 13:07:08 +0000 (08:07 -0500)
This is problematic as this usually gets invoked via the Mgr remote
method, which will clobber any exception with a RuntimeError.

Instead, just have it return None if one isn't configured, and have the
callers raise the exception if necessary.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/pybind/mgr/orchestrator.py
src/pybind/mgr/orchestrator_cli/module.py

index d67f7996edc2ce977b7c7e5126f28ec6cfe230c8..b68aefed7c9b61db918b3828efc9613e1a1be4da 100644 (file)
@@ -812,6 +812,10 @@ class OrchestratorClientMixin(Orchestrator):
             o = self._select_orchestrator()
         except AttributeError:
             o = self.remote('orchestrator_cli', '_select_orchestrator')
+
+        if o is None:
+            raise NoOrchestrator()
+
         self.log.debug("_oremote {} -> {}.{}(*{}, **{})".format(self.module_name, o, meth, args, kwargs))
         return self.remote(o, meth, *args, **kwargs)
 
index 7fad8bbedd11edc02e82822b01a49b812e0d9020..462586d42e61e2357145fe2c1e429fefda095fca 100644 (file)
@@ -30,11 +30,7 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule):
     ]
 
     def _select_orchestrator(self):
-        o = self.get_module_option("orchestrator")
-        if o is None:
-            raise NoOrchestrator()
-
-        return o
+        return self.get_module_option("orchestrator")
 
     @CLIReadCommand('orchestrator device ls',
                     "name=host,type=CephString,n=N,req=false "
@@ -319,14 +315,16 @@ Usage:
                     desc='Report configured backend and its status')
     @handle_exceptions
     def _status(self):
-        avail, why = self.available()
+        o = self._select_orchestrator()
+        if o is None:
+            raise orchestrator.NoOrchestrator()
 
+        avail, why = self.available()
         if avail is None:
             # The module does not report its availability
-            return HandleCommandResult(stdout="Backend: {0}".format(self._select_orchestrator()))
+            return HandleCommandResult(stdout="Backend: {0}".format(o))
         else:
             return HandleCommandResult(stdout="Backend: {0}\nAvailable: {1}{2}".format(
-                                           self._select_orchestrator(),
-                                           avail,
+                                           o, avail,
                                            " ({0})".format(why) if not avail else ""
                                        ))