]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/progress: Add pg_ready interface for python to get pgmap_ready state
authorDavid Zafman <dzafman@redhat.com>
Thu, 9 Jan 2020 00:02:51 +0000 (16:02 -0800)
committerNathan Cutler <ncutler@suse.com>
Thu, 28 May 2020 16:38:21 +0000 (18:38 +0200)
Fixes: https://tracker.ceph.com/issues/43557
Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit 563811a0f60ad225c0f38b7359f84667043c2017)

Conflicts:
src/pybind/mgr/progress/module.py
- adapted for post-nautilus cleanups
src/pybind/mgr/progress/test_progress.py
- file not present in nautilus

src/mgr/ActivePyModules.cc
src/mgr/DaemonServer.cc
src/mgr/DaemonServer.h
src/pybind/mgr/mgr_module.py
src/pybind/mgr/progress/module.py
src/pybind/mgr/selftest/module.py

index ee022e875e969703375fba8f5b256ae3216811d0..cd334b7016c5b7a5c269866e3204c000c29718b3 100644 (file)
@@ -372,6 +372,10 @@ PyObject *ActivePyModules::get_python(const std::string &what)
       pg_map.dump_pool_stats(&f);
     });
     return f.get();
+  } else if (what == "pg_ready") {
+    PyEval_RestoreThread(tstate);
+    server.dump_pg_ready(&f);
+    return f.get();
   } else if (what == "osd_stats") {
     cluster_state.with_pgmap(
         [&f, &tstate](const PGMap &pg_map) {
index 93e770ad9cec105f3e64219227c3bf0ddaaa56ad..0e7a795be8a2401a5d6b377830d2c234181ba828 100644 (file)
@@ -288,6 +288,11 @@ bool DaemonServer::ms_dispatch(Message *m)
   };
 }
 
+void DaemonServer::dump_pg_ready(ceph::Formatter *f)
+{
+  f->dump_bool("pg_ready", pgmap_ready.load());
+}
+
 void DaemonServer::maybe_ready(int32_t osd_id)
 {
   if (pgmap_ready.load()) {
index 0bc0ad75cc1860fe25cf73ad80e1eca8d68e3c79..3c73d84c53cc050770070770162cf55b13b0bb8d 100644 (file)
@@ -174,6 +174,7 @@ public:
 
   void log_access_denied(std::shared_ptr<CommandContext>& cmdctx,
                          MgrSession* session, std::stringstream& ss);
+  void dump_pg_ready(ceph::Formatter *f);
 };
 
 #endif
index 4e7e923b71901f7f1b30bb36bead84f2723b6670..4ca31308cb4718e7346f3f3b4e977f19d06f1ba9 100644 (file)
@@ -702,7 +702,7 @@ class MgrModule(ceph_module.BaseMgrModule):
                 osd_map, osd_map_tree, osd_map_crush, config, mon_map, fs_map,
                 osd_metadata, pg_summary, io_rate, pg_dump, df, osd_stats,
                 health, mon_status, devices, device <devid>, pg_stats,
-                pool_stats.
+                pool_stats, pg_ready.
 
         Note:
             All these structures have their own JSON representations: experiment
index ce81aaee3bbd27a69ed8bcbcb8ca6e5a8cc97cdd..fa66e40890e960d2a8d1cec3f0cbe5699179a2af 100644 (file)
@@ -191,7 +191,7 @@ class PgRecoveryEvent(Event):
     def evacuating_osds(self):
         return self. _evacuate_osds
 
-    def pg_update(self, raw_pg_stats, log):
+    def pg_update(self, raw_pg_stats, pg_ready, log):
         # FIXME: O(pg_num) in python
         # FIXME: far more fields getting pythonized than we really care about
         pg_to_state = dict([(p['pgid'], p) for p in raw_pg_stats['pg_stats']])
@@ -206,7 +206,7 @@ class PgRecoveryEvent(Event):
                         pg_to_state[pg_str]['stat_sum']['num_bytes_recovered']
                 else:
                     missing_pgs.append(pg)
-            if pg_dump.get('pg_ready', False):
+            if pg_ready:
                 for pg in missing_pgs:
                     self._pgs.remove(pg)
 
@@ -409,7 +409,7 @@ class Module(MgrModule):
             which_pgs=affected_pgs,
             evacuate_osds=[osd_id]
         )
-        ev.pg_update(self.get("pg_stats"), self.log)
+        ev.pg_update(self.get("pg_stats"), self.get("pg_ready"), self.log)
         self._events[ev.id] = ev
 
     def _osd_in(self, osd_id):
@@ -455,9 +455,10 @@ class Module(MgrModule):
             self._osdmap_changed(old_osdmap, self._latest_osdmap)
         elif notify_type == "pg_summary":
             data = self.get("pg_stats")
+            ready = self.get("pg_ready")
             for ev_id, ev in self._events.items():
                 if isinstance(ev, PgRecoveryEvent):
-                    ev.pg_update(data, self.log)
+                    ev.pg_update(data, ready, self.log)
                     self.maybe_complete(ev)
 
     def maybe_complete(self, event):
index 5a1a8a5fb8d363c65d72ffa42b3835afa8cdebc3..0bbd773550b786c51407fda21af04b7a3b24fe66 100644 (file)
@@ -236,6 +236,7 @@ class Module(MgrModule):
                 "pg_summary",
                 "pg_status",
                 "pg_dump",
+                "pg_ready",
                 "df",
                 "pg_stats",
                 "pool_stats",