]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: update metadata if an osd just joins 33834/head
authorKefu Chai <kchai@redhat.com>
Thu, 5 Mar 2020 15:42:13 +0000 (23:42 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 10 Mar 2020 05:03:11 +0000 (13:03 +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>
(cherry picked from commit 73078cf73c3a51f33ecb97eebbb97dbcd4089171)

Conflicts:
src/mgr/Mgr.cc: trivial resolution

src/mgr/Mgr.cc

index eb368307e40315404508ce8ef9fa11a09b903a1a..888d93892ece652aab5fe1455ac52fa636a1abe3 100644 (file)
@@ -449,37 +449,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", stringify(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;