]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr: update metadata if an osd just joins
authorKefu Chai <kchai@redhat.com>
Thu, 5 Mar 2020 15:42:13 +0000 (23:42 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 5 Mar 2020 16:01:45 +0000 (00:01 +0800)
instead of using "front_address" for checking if we have a new OSD
reusing existing a known identify shows up in the osdmap, it'd be
simpler to compare the up_from epoch with the osdmap's epoch. as
objecter will subscribe **every** osdmap after mgr boots. so mgr
should be able to see the osdmap when the osd joins the cluster
where the up_from epoch is identical to osdmap's epoch.

this way is simpler than existing approach. but it will involve
more overhead if osd reboots frequently without changing their
metadata.

before this change, the metadata is requested/updated only if
the public (front) address is changed.

after this change, the metadata is requested/updated whenever
an osd reboots.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/Mgr.cc

index da24a24d0bf8d4fa875fba386a63e9ca7e66df61..367942717e33761642e6fec7d5015775128c48ff 100644 (file)
@@ -465,37 +465,22 @@ void Mgr::handle_osd_map()
       names_exist.insert(stringify(osd_id));
 
       // Consider whether to update the daemon metadata (new/restarted daemon)
-      bool update_meta = false;
       const auto k = DaemonKey{"osd", std::to_string(osd_id)};
       if (daemon_state.is_updating(k)) {
         continue;
       }
 
+      bool update_meta = false;
       if (daemon_state.exists(k)) {
-        auto metadata = daemon_state.get(k);
-       std::lock_guard l(metadata->lock);
-        auto addr_iter = metadata->metadata.find("front_addr");
-        if (addr_iter != metadata->metadata.end()) {
-          const std::string &metadata_addr = addr_iter->second;
-          const auto &map_addrs = osd_map.get_addrs(osd_id);
-
-          if (metadata_addr != stringify(map_addrs)) {
-            dout(4) << "OSD[" << osd_id << "] addr change " << metadata_addr
-                    << " != " << stringify(map_addrs) << dendl;
-            update_meta = true;
-          } else {
-            dout(20) << "OSD[" << osd_id << "] addr unchanged: "
-                     << metadata_addr << dendl;
-          }
-        } else {
-          // Awkward case where daemon went into DaemonState because it
-          // sent us a report but its metadata didn't get loaded yet
+        if (osd_map.get_up_from(osd_id) == osd_map.get_epoch()) {
+          dout(4) << "Mgr::handle_osd_map: osd." << osd_id
+                 << " joined cluster at " << "e" << osd_map.get_epoch()
+                 << dendl;
           update_meta = true;
         }
       } else {
         update_meta = true;
       }
-
       if (update_meta) {
         auto c = new MetadataUpdate(daemon_state, k);
         std::ostringstream cmd;