From 36b59c8d42375d151941d53dec1e6dcd1494a197 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 13 May 2019 11:46:57 +0200 Subject: [PATCH] mgr/rook: Raise proper exception in `describe_service` `describe_service` is called often and raising assertions will pollute the log file with tracebacks. Signed-off-by: Sebastian Wagner --- src/pybind/mgr/rook/module.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index bf377b83ed5..a2653512099 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -182,10 +182,11 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): try: c.execute() except Exception as e: - self.log.exception("Completion {0} threw an exception:".format( - c.message - )) - c.error = e + if not isinstance(e, orchestrator.OrchestratorError): + self.log.exception("Completion {0} threw an exception:".format( + c.message + )) + c.exception = e c._complete = True if not c.is_complete: @@ -331,7 +332,8 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): @deferred_read def describe_service(self, service_type=None, service_id=None, node_name=None): - assert service_type in ("mds", "osd", "mgr", "mon", "nfs", None), service_type + " unsupported" + if service_type not in ("mds", "osd", "mgr", "mon", "nfs", None): + raise orchestrator.OrchestratorValidationError(service_type + " unsupported") pods = self.rook_cluster.describe_pods(service_type, service_id, node_name) -- 2.39.5