From: David Zafman Date: Thu, 9 Jan 2020 00:02:51 +0000 (-0800) Subject: mgr/progress: Add pg_ready interface for python to get pgmap_ready state X-Git-Tag: v15.1.1~215^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=563811a0f60ad225c0f38b7359f84667043c2017;p=ceph.git mgr/progress: Add pg_ready interface for python to get pgmap_ready state Fixes: https://tracker.ceph.com/issues/43557 Signed-off-by: David Zafman --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 10b7e0d4e2d5..6546711aa7a0 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -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) { diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 8bbac9651516..4e330c4cd60f 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -266,6 +266,11 @@ bool DaemonServer::ms_dispatch2(const ref_t& 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()) { diff --git a/src/mgr/DaemonServer.h b/src/mgr/DaemonServer.h index 6289176c9e02..41b25a3bc311 100644 --- a/src/mgr/DaemonServer.h +++ b/src/mgr/DaemonServer.h @@ -194,6 +194,7 @@ public: void log_access_denied(std::shared_ptr& cmdctx, MgrSession* session, std::stringstream& ss); + void dump_pg_ready(ceph::Formatter *f); }; #endif diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 9186ca46035d..63e4353517bc 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -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 , pg_stats, - pool_stats. + pool_stats, pg_ready. Note: All these structures have their own JSON representations: experiment diff --git a/src/pybind/mgr/progress/module.py b/src/pybind/mgr/progress/module.py index 89c097e50143..4cc52a179d93 100644 --- a/src/pybind/mgr/progress/module.py +++ b/src/pybind/mgr/progress/module.py @@ -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): diff --git a/src/pybind/mgr/progress/test_progress.py b/src/pybind/mgr/progress/test_progress.py index db2013deb3f2..52f2ae716637 100644 --- a/src/pybind/mgr/progress/test_progress.py +++ b/src/pybind/mgr/progress/test_progress.py @@ -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: diff --git a/src/pybind/mgr/selftest/module.py b/src/pybind/mgr/selftest/module.py index 6f8c7118c111..d9c38ac1df08 100644 --- a/src/pybind/mgr/selftest/module.py +++ b/src/pybind/mgr/selftest/module.py @@ -237,6 +237,7 @@ class Module(MgrModule): "pg_summary", "pg_status", "pg_dump", + "pg_ready", "df", "pg_stats", "pool_stats",