]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: establish session with mgr only after added to FSMap
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 6 Nov 2019 03:51:17 +0000 (19:51 -0800)
committerVenky Shankar <vshankar@redhat.com>
Thu, 26 Mar 2020 02:45:13 +0000 (22:45 -0400)
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>
(cherry picked from commit e765f2d533440cfc4189f36fcaba24617a302e84)

 Conflicts:
src/mds/MDSDaemon.cc

Nautilus uses Lock/Unlock rather than lock/unlock in master.

src/mds/MDSDaemon.cc
src/mgr/MgrClient.cc
src/mgr/MgrClient.h

index 276d23268707b5dec05c62b0ced5328b4e654e4f..d9699366a1fb16749bac878f7074ce72a04351ba 100644 (file)
@@ -416,9 +416,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;
@@ -427,7 +424,6 @@ int MDSDaemon::init()
   }
 
   monc->sub_want("mdsmap", 0, 0);
-  monc->sub_want("mgrmap", 0, 0);
   monc->renew_subs();
 
   mds_lock.Unlock();
@@ -832,6 +828,14 @@ void MDSDaemon::handle_mds_map(const MMDSMap::const_ref &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) {
@@ -933,7 +937,8 @@ void MDSDaemon::suicide()
   }
   beacon.shutdown();
 
-  mgrc.shutdown();
+  if (mgrc.is_initialized())
+    mgrc.shutdown();
 
   if (mds_rank) {
     mds_rank->shutdown();
index 0d768dd216652f9d9ffb4ad3c7b32236824d6ac8..738e9a3b116908307868c38c5629d8a3a4e429c8 100644 (file)
@@ -44,6 +44,7 @@ void MgrClient::init()
   ceph_assert(msgr != nullptr);
 
   timer.init();
+  initialized = true;
 }
 
 void MgrClient::shutdown()
index 35c36e23fd8c72661c0433a2e0b5fc6ffb1548b1..e7a6cc779f3dba8a1c4cca644dab08c7e389a3c7 100644 (file)
@@ -153,10 +153,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