From: Kefu Chai Date: Thu, 5 Mar 2020 15:42:13 +0000 (+0800) Subject: mgr: update metadata if an osd just joins X-Git-Tag: v15.1.1~77^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=73078cf73c3a51f33ecb97eebbb97dbcd4089171;p=ceph-ci.git mgr: update metadata if an osd just joins 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 --- diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index da24a24d0bf..367942717e3 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -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;