]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: implement flush_pg_stats command
authorKefu Chai <kchai@redhat.com>
Fri, 3 Jul 2020 08:05:56 +0000 (16:05 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 3 Jul 2020 08:09:38 +0000 (16:09 +0800)
this command is used by teuthology based tests for updating the mgr with
the lastes pg stats on OSD.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/admin/osd_admin.cc
src/crimson/admin/osd_admin.h
src/crimson/mgr/client.h
src/crimson/osd/osd.cc
src/crimson/osd/osd.h

index a8e0a475363d3900d6198b9efb03506b9cd2ffa9..4675d8d2230c8cb6f9e49f00611ae4fb8ed3ab90 100644 (file)
@@ -178,6 +178,32 @@ public:
 };
 template std::unique_ptr<AdminSocketHook> make_asok_hook<ConfigSetHook>();
 
+/**
+ * send the latest pg stats to mgr
+ */
+class FlushPgStatsHook : public AdminSocketHook {
+public:
+  explicit FlushPgStatsHook(crimson::osd::OSD& osd) :
+    AdminSocketHook("flush_pg_stats",
+                   "flush_pg_stats",
+                   "flush pg stats"),
+    osd{osd}
+  {}
+  seastar::future<tell_result_t> call(const cmdmap_t&,
+                                     std::string_view format,
+                                     ceph::bufferlist&& input) const final
+  {
+    uint64_t seq = osd.send_pg_stats();
+    unique_ptr<Formatter> f{Formatter::create(format, "json-pretty", "json-pretty")};
+    f->dump_unsigned("stat_seq", seq);
+    return seastar::make_ready_future<tell_result_t>(tell_result_t(f.get()));
+  }
+
+private:
+  crimson::osd::OSD& osd;
+};
+template std::unique_ptr<AdminSocketHook> make_asok_hook<FlushPgStatsHook>(crimson::osd::OSD& osd);
+
 /**
  * A CephContext admin hook: calling assert (if allowed by
  * 'debug_asok_assert_abort')
index 2fd82fddb5e8e4bfecc3b57fddf1873f964528f6..6a0b8b230ba705a0383070ecde12d4ed6d8d921d 100644 (file)
@@ -8,12 +8,13 @@
 
 namespace crimson::admin {
 
-class OsdStatusHook;
-class SendBeaconHook;
+class AssertAlwaysHook;
 class ConfigShowHook;
 class ConfigGetHook;
 class ConfigSetHook;
-class AssertAlwaysHook;
+class FlushPgStatsHook;
+class OsdStatusHook;
+class SendBeaconHook;
 
 template<class Hook, class... Args>
 std::unique_ptr<AdminSocketHook> make_asok_hook(Args&&... args);
index 919fdeb608036e126740edeb0c01ef1b45baf254..742cf0c002610c5b03867eda9110269ba4160013 100644 (file)
@@ -35,6 +35,8 @@ public:
         WithStats& with_stats);
   seastar::future<> start();
   seastar::future<> stop();
+  void report();
+
 private:
   seastar::future<> ms_dispatch(crimson::net::Connection* conn,
                                Ref<Message> m) override;
@@ -45,7 +47,6 @@ private:
   seastar::future<> handle_mgr_conf(crimson::net::Connection* conn,
                                    Ref<MMgrConfigure> m);
   seastar::future<> reconnect();
-  void report();
 
   void print(std::ostream&) const;
   friend std::ostream& operator<<(std::ostream& out, const Client& client);
index 0744d98d5ea5c9b70c12bb79435ffd5b41b11a5f..4c72ccd58922608ae028dc7e75ba7ae7730ca624 100644 (file)
@@ -451,7 +451,8 @@ seastar::future<> OSD::start_asok_admin()
       asok->register_command(make_asok_hook<SendBeaconHook>(*this)),
       asok->register_command(make_asok_hook<ConfigShowHook>()),
       asok->register_command(make_asok_hook<ConfigGetHook>()),
-      asok->register_command(make_asok_hook<ConfigSetHook>()));
+      asok->register_command(make_asok_hook<ConfigSetHook>()),
+      asok->register_command(make_asok_hook<FlushPgStatsHook>(*this)));
   });
 }
 
@@ -708,6 +709,13 @@ MessageRef OSD::get_stats() const
   return m;
 }
 
+uint64_t OSD::send_pg_stats()
+{
+  // mgr client sends the report message in background
+  mgrc->report();
+  return osd_stat_seq;
+}
+
 OSD::cached_map_t OSD::get_map() const
 {
   return osdmap;
index 0e8723ab8dd5cdc0b7b3295563903cc68931d831..afee53d69dece4a5a6e5d8c3f6843ac25e6703b4 100644 (file)
@@ -139,6 +139,10 @@ public:
 
   seastar::future<> send_incremental_map(crimson::net::Connection* conn,
                                         epoch_t first);
+
+  /// @return the seq id of the pg stats being sent
+  uint64_t send_pg_stats();
+
 private:
   seastar::future<> start_boot();
   seastar::future<> _preboot(version_t oldest_osdmap, version_t newest_osdmap);