From 861930c64ca060a74d5db541a451decf838ba93b Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 5 Mar 2020 23:42:13 +0800 Subject: [PATCH] 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 (cherry picked from commit 73078cf73c3a51f33ecb97eebbb97dbcd4089171) Conflicts: src/mgr/Mgr.cc: trivial resolution --- src/mgr/Mgr.cc | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index eb368307e403..888d93892ece 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -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; -- 2.47.3