]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: establish session with mgr only after added to FSMap 31400/head
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 6 Nov 2019 03:51:17 +0000 (19:51 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 8 Nov 2019 18:02:12 +0000 (10:02 -0800)
Note that we now sub to the mgrmap after init because the MgrClient
connection to the mgr is driven by receipt of the MgrMap.

This is important so that the MDS does not have metadata with the mgr
when the mons are ignoring the MDS otherwise due to CompatSet
incompatibilities.

Fixes: https://tracker.ceph.com/issues/41538
Fixes: https://tracker.ceph.com/issues/42635
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/MDSDaemon.cc
src/mgr/MgrClient.cc
src/mgr/MgrClient.h

index 6e65323ce02735159e1092690ba3bda427d8ad04..45356177b990c6da84b90fb0fe39438efc963d1f 100644 (file)
@@ -386,9 +386,6 @@ int MDSDaemon::init()
     return -ETIMEDOUT;
   }
 
-  mgrc.init();
-  messenger->add_dispatcher_head(&mgrc);
-
   mds_lock.lock();
   if (beacon.get_want_state() == CEPH_MDS_STATE_DNE) {
     dout(4) << __func__ << ": terminated already, dropping out" << dendl;
@@ -397,7 +394,6 @@ int MDSDaemon::init()
   }
 
   monc->sub_want("mdsmap", 0, 0);
-  monc->sub_want("mgrmap", 0, 0);
   monc->renew_subs();
 
   mds_lock.unlock();
@@ -799,6 +795,14 @@ void MDSDaemon::handle_mds_map(const cref_t<MMDSMap> &m)
     respawn();
   }
 
+  if (old_state == DS::STATE_NULL && new_state != DS::STATE_NULL) {
+    /* The MDS has been added to the FSMap, now we can init the MgrClient */
+    mgrc.init();
+    messenger->add_dispatcher_tail(&mgrc);
+    monc->sub_want("mgrmap", 0, 0);
+    monc->renew_subs(); /* MgrMap receipt drives connection to ceph-mgr */
+  }
+
   // mark down any failed peers
   for (const auto& [gid, info] : oldmap->get_mds_info()) {
     if (mdsmap->get_mds_info().count(gid) == 0) {
@@ -899,7 +903,8 @@ void MDSDaemon::suicide()
   }
   beacon.shutdown();
 
-  mgrc.shutdown();
+  if (mgrc.is_initialized())
+    mgrc.shutdown();
 
   if (mds_rank) {
     mds_rank->shutdown();
index 976d297e639a05b4ce567bd5c6ef5846f71c030e..0667d8c727357439ee05a9755eac0d5be902eba6 100644 (file)
@@ -55,6 +55,7 @@ void MgrClient::init()
   ceph_assert(msgr != nullptr);
 
   timer.init();
+  initialized = true;
 }
 
 void MgrClient::shutdown()
index 7e5272dbedbeebacbeb148fa53ebc6bea998ccd1..e9053ccf1f0279a67795fd46bac5f3227c3d980d 100644 (file)
@@ -168,10 +168,14 @@ public:
     std::map<std::string,std::string> &&task_status);
   void update_daemon_health(std::vector<DaemonHealthMetric>&& metrics);
 
+  bool is_initialized() const { return initialized; }
+
 private:
   void _send_stats();
   void _send_pgstats();
   void _send_report();
+
+  bool initialized = false;
 };
 
 #endif