]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator: Improve debuggability 24147/head
authorSebastian Wagner <sebastian.wagner@suse.com>
Tue, 18 Sep 2018 14:09:51 +0000 (16:09 +0200)
committerSebastian Wagner <sebastian.wagner@suse.com>
Tue, 18 Sep 2018 14:09:51 +0000 (16:09 +0200)
* `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 <sebastian.wagner@suse.com>
src/pybind/mgr/orchestrator_cli/module.py
src/pybind/mgr/rook/module.py

index 560cc073ff89630d1dba888f7cfbb81bcdf13cf2..8c406333425b424ea73dec799fe983f5ac36c932 100644 (file)
@@ -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)
 
index 4e9a69066c2d491f754e45e4f5cb2f7cb4a8d6c1..dafd1191aa8b28451fd668fae413018ece085606 100644 (file)
@@ -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)