]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: send scrub status to ceph-mgr only when scrub is running
authorVenky Shankar <vshankar@redhat.com>
Thu, 23 Apr 2020 06:21:01 +0000 (02:21 -0400)
committerVenky Shankar <vshankar@redhat.com>
Thu, 9 Jul 2020 03:49:40 +0000 (23:49 -0400)
Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/mds/MDSRank.cc
src/mds/MDSRank.h
src/mds/ScrubStack.h
src/mgr/DaemonServer.cc

index 161adeb4d744d0dc9cff9b254ffbbe95e8e59bf0..5847dc10a3312894fe9708fa3f7684d391c37f10 100644 (file)
@@ -3676,7 +3676,10 @@ void MDSRank::get_task_status(std::map<std::string, std::string> *status) {
 
   // scrub summary for now..
   std::string_view scrub_summary = scrubstack->scrub_summary();
-  status->emplace(SCRUB_STATUS_KEY, std::move(scrub_summary));
+  if (!ScrubStack::is_idle(scrub_summary)) {
+    send_status = true;
+    status->emplace(SCRUB_STATUS_KEY, std::move(scrub_summary));
+  }
 }
 
 void MDSRank::schedule_update_timer_task() {
@@ -3692,13 +3695,17 @@ void MDSRank::send_task_status() {
   std::map<std::string, std::string> status;
   get_task_status(&status);
 
-  if (!status.empty()) {
-    dout(20) << __func__ << ": updating " << status.size() << " status keys" << dendl;
+  if (send_status) {
+    if (status.empty()) {
+      send_status = false;
+    }
 
+    dout(20) << __func__ << ": updating " << status.size() << " status keys" << dendl;
     int r = mgrc->service_daemon_update_task_status(std::move(status));
     if (r < 0) {
       derr << ": failed to update service daemon status: " << cpp_strerror(r) << dendl;
     }
+
   }
 
   schedule_update_timer_task();
index 51a87a93597ff116ffd32cf3c09d272d84c8dae6..69455993527bed44821e69b4879f657a62d3765f 100644 (file)
@@ -581,6 +581,8 @@ class MDSRank {
 
     bool standby_replaying = false;  // true if current replay pass is in standby-replay mode
 private:
+    bool send_status = true;
+
     // "task" string that gets displayed in ceph status
     inline static const std::string SCRUB_STATUS_KEY = "scrub status";
 
index da037cabbab2541042e46a4aee5b763334c9ec73..127679b48126f74482b6e25fcd16bf17af6a9edf 100644 (file)
@@ -105,6 +105,10 @@ public:
    */
   std::string_view scrub_summary();
 
+  static bool is_idle(std::string_view state_str) {
+    return state_str == "idle";
+  }
+
   bool is_scrubbing() const { return !inode_stack.empty(); }
 
   MDCache *mdcache;
index 1fc57233e39cd709c3f2c1f5e4852badc4b444d8..302948fc2068a0b8266548a743c5f1f2a83e0de9 100644 (file)
@@ -551,9 +551,21 @@ bool DaemonServer::handle_close(const ref_t<MMgrClose>& m)
 void DaemonServer::update_task_status(DaemonKey key, const ref_t<MMgrReport>& m) {
   dout(10) << "got task status from " << key << dendl;
 
-  auto p = pending_service_map.get_daemon(key.type, key.name);
-  if (!map_compare(p.first->task_status, *m->task_status)) {
-    p.first->task_status = *m->task_status;
+  bool service_map_dirty = false;
+  if ((*m->task_status).empty()) {
+    auto removed = pending_service_map.rm_daemon(key.type, key.name);
+    if (removed) {
+      service_map_dirty = true;
+    }
+  } else {
+    auto p = pending_service_map.get_daemon(key.type, key.name);
+    if (!map_compare(p.first->task_status, *m->task_status)) {
+      service_map_dirty = true;
+      p.first->task_status = *m->task_status;
+    }
+  }
+
+  if (service_map_dirty) {
     pending_service_map_dirty = pending_service_map.epoch;
   }
 }