]> git.apps.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)
committerDavid Zafman <dzafman@redhat.com>
Thu, 27 Feb 2020 21:12:45 +0000 (13:12 -0800)
Fixes: https://tracker.ceph.com/issues/43557
Signed-off-by: David Zafman <dzafman@redhat.com>
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/progress/test_progress.py
src/pybind/mgr/selftest/module.py

index 10b7e0d4e2d5185656762e1fa8befa1289856b69..6546711aa7a041c2fb1c84e8f25debcb3861c493 100644 (file)
@@ -383,6 +383,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 8bbac9651516dd09912abe20cf8e33d3573aa864..4e330c4cd60f17b7176851a420d4c96c0a5664e7 100644 (file)
@@ -266,6 +266,11 @@ bool DaemonServer::ms_dispatch2(const ref_t<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 6289176c9e02fc59fc456cb9148bee6e710daef1..41b25a3bc3114042e8cf2916b972e2aff5c7d6bf 100644 (file)
@@ -194,6 +194,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 9186ca46035dd49e321508f2d55f86e179d9c456..63e4353517bcba2a53a40e4c750f2bc57631168c 100644 (file)
@@ -796,7 +796,7 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
                 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 89c097e50143303679c58f2e46762b9158188cb0..4cc52a179d93ec26d1512da8127546493cb790a9 100644 (file)
@@ -257,8 +257,8 @@ class PgRecoveryEvent(Event):
     def which_osds(self):
         return self. _which_osds
 
-    def pg_update(self, raw_pg_stats, log):
-        # type: (Dict, Any) -> None
+    def pg_update(self, raw_pg_stats, pg_ready, log):
+        # type: (Dict, bool, Any) -> None
         # FIXME: O(pg_num) in python
         # FIXME: far more fields getting pythonized than we really care about
         # Sanity check to see if there are any missing PGs and to assign
@@ -274,7 +274,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)
 
@@ -501,7 +501,7 @@ class Module(MgrModule):
                     which_osds=[osd_id],
                     start_epoch=self.get_osdmap().get_epoch()
                     )
-            r_ev.pg_update(self.get("pg_stats"), self.log)
+            r_ev.pg_update(self.get("pg_stats"), self.get("pg_ready"), self.log)
             self._events[r_ev.id] = r_ev
 
     def _osdmap_changed(self, old_osdmap, new_osdmap):
@@ -542,10 +542,11 @@ 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 in list(self._events):
                 ev = self._events[ev_id]
                 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 db2013deb3f2cc57b6a3681be8ace8dd7453d2de..52f2ae716637b4bc722ae0b8cd50b4d3f3a28228 100644 (file)
@@ -21,7 +21,7 @@ class TestPgRecoveryEvent(object):
 
     def test_pg_update(self):
         # Test for a completed event when the pg states show active+clear
-        pg_dump = {
+        pg_stats = {
                 "pg_stats":[
         {
           "state": "active+clean",
@@ -77,7 +77,7 @@ class TestPgRecoveryEvent(object):
         ]
         }
 
-        self.test_event.pg_update(pg_dump, mock.Mock())
+        self.test_event.pg_update(pg_stats, True, mock.Mock())
         assert self.test_event._progress == 1.0
        
 class OSDMap: 
index 6f8c7118c1118e4f73b90685c5b52d238ea20a5b..d9c38ac1df08c361cf728c7de292cf6ab0274b47 100644 (file)
@@ -237,6 +237,7 @@ class Module(MgrModule):
                 "pg_summary",
                 "pg_status",
                 "pg_dump",
+                "pg_ready",
                 "df",
                 "pg_stats",
                 "pool_stats",