From 98b8f7922a23ea8bf9532e7ad2218591060c4c9a Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Tue, 12 Feb 2019 07:16:06 -0500 Subject: [PATCH] mgr/orchestrator: don't have _select_orchestrator raise exceptions 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 --- src/pybind/mgr/orchestrator.py | 4 ++++ src/pybind/mgr/orchestrator_cli/module.py | 16 +++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index d67f7996edc2c..b68aefed7c9b6 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -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) diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 7fad8bbedd11e..462586d42e61e 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -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 "" )) -- 2.39.5