]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mgr/MgrStandby.cc
update sources to v12.1.2
[ceph.git] / ceph / src / mgr / MgrStandby.cc
index 5e82de97f4c96a6360d3d9281cf90b2fd91bda4c..99df69c909fdea44512973aabe69e3e45990d525 100644 (file)
@@ -48,7 +48,8 @@ MgrStandby::MgrStandby(int argc, const char **argv) :
   timer(g_ceph_context, lock),
   active_mgr(nullptr),
   orig_argc(argc),
-  orig_argv(argv)
+  orig_argv(argv),
+  available_in_map(false)
 {
 }
 
@@ -151,17 +152,35 @@ void MgrStandby::send_beacon()
 
   set<string> modules;
   PyModules::list_modules(&modules);
+
+  // Whether I think I am available (request MgrMonitor to set me
+  // as available in the map)
   bool available = active_mgr != nullptr && active_mgr->is_initialized();
+
   auto addr = available ? active_mgr->get_server_addr() : entity_addr_t();
   dout(10) << "sending beacon as gid " << monc.get_global_id()
           << " modules " << modules << dendl;
 
+  map<string,string> metadata;
+  collect_sys_info(&metadata, g_ceph_context);
+
   MMgrBeacon *m = new MMgrBeacon(monc.get_fsid(),
                                 monc.get_global_id(),
                                  g_conf->name.get_id(),
                                  addr,
                                  available,
-                                modules);
+                                modules,
+                                std::move(metadata));
+
+  if (available && !available_in_map) {
+    // We are informing the mon that we are done initializing: inform
+    // it of our command set.  This has to happen after init() because
+    // it needs the python modules to have loaded.
+    m->set_command_descs(active_mgr->get_command_set());
+    dout(4) << "going active, including " << m->get_command_descs().size()
+            << " commands in beacon" << dendl;
+  }
+                                 
   monc.send_mon_message(m);
 }
 
@@ -278,7 +297,7 @@ void MgrStandby::_update_log_config()
 
 void MgrStandby::handle_mgr_map(MMgrMap* mmap)
 {
-  auto map = mmap->get_map();
+  auto &map = mmap->get_map();
   dout(4) << "received map epoch " << map.get_epoch() << dendl;
   const bool active_in_map = map.active_gid == monc.get_global_id();
   dout(4) << "active in map: " << active_in_map
@@ -303,6 +322,11 @@ void MgrStandby::handle_mgr_map(MMgrMap* mmap)
        respawn();
       }
     }
+
+    if (!available_in_map && map.get_available()) {
+      dout(4) << "Map now says I am available" << dendl;
+      available_in_map = true;
+    }
   } else {
     if (active_mgr != nullptr) {
       derr << "I was active but no longer am" << dendl;