From: Sebastian Wagner Date: Tue, 18 Sep 2018 14:09:51 +0000 (+0200) Subject: mgr/orchestrator: Improve debuggability X-Git-Tag: v14.0.1~140^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f81f7ecc084d8b8252b30cc922e33459960bbdf6;p=ceph.git mgr/orchestrator: Improve debuggability * `OrchestratorCli._wait()`: raise exception if all completions failed. Otherwise we will have an infinite loop here. * The "Kubernetes module" is actually called `kubernetes`. * Ignore k8s errors in `RookOrchestrator.serve()` , in order to provide an error message in `orchestrator status` * Assert with error message Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 560cc073ff89..8c406333425b 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -90,6 +90,9 @@ class OrchestratorCli(MgrModule): else: done = True + if all(hasattr(c, 'error') and getattr(c, 'error')for c in completions): + raise Exception([getattr(c, 'error') for c in completions]) + def _list_devices(self, cmd): node = cmd.get('node', None) diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index 4e9a69066c2d..dafd1191aa8b 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -164,6 +164,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): c.message )) c.error = e + c._complete = True if not c.is_read: self._progress("complete", c.id) else: @@ -181,18 +182,18 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): if kubernetes_imported: return True, "" else: - return False, "Kubernetes module not found" + return False, "`kubernetes` module not found" def available(self): if not kubernetes_imported: - return False, "Kubernetes module not found" + return False, "`kubernetes` module not found" elif not self._in_cluster(): return False, "ceph-mgr not running in Rook cluster" try: self.k8s.list_namespaced_pod(self.rook_cluster.cluster_name) - except ApiException: - return False, "Cannot reach Kubernetes API" + except ApiException as e: + return False, "Cannot reach Kubernetes API: {}".format(e) else: return True, "" @@ -247,16 +248,21 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): self._k8s = client.CoreV1Api() - # XXX mystery hack -- I need to do an API call from - # this context, or subsequent API usage from handle_command - # fails with SSLError('bad handshake'). Suspect some kind of - # thread context setup in SSL lib? - self._k8s.list_namespaced_pod(cluster_name) + try: + # XXX mystery hack -- I need to do an API call from + # this context, or subsequent API usage from handle_command + # fails with SSLError('bad handshake'). Suspect some kind of + # thread context setup in SSL lib? + self._k8s.list_namespaced_pod(cluster_name) + except ApiException: + # Ignore here to make self.available() fail with a proper error message + pass self._rook_cluster = RookCluster( self._k8s, cluster_name) + # In case Rook isn't already clued in to this ceph # cluster's existence, initialize it. # self._rook_cluster.init_rook() @@ -320,7 +326,8 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): @deferred_read def describe_service(self, service_type, service_id): - assert service_type in ("mds", "osd", "mon", "rgw") + + assert service_type in ("mds", "osd", "mon", "rgw"), service_type + " unsupported" pods = self.rook_cluster.describe_pods(service_type, service_id)