mon: use single collect_metadata helper, consistently set 'addr'

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2017-07-05 15:43:33 -04:00
parent 9099d56e05
commit c9fa52eab5
2 changed files with 9 additions and 3 deletions

View File

@ -1945,8 +1945,7 @@ void Monitor::win_election(epoch_t epoch, set<int>& active, uint64_t features,
}
Metadata my_meta;
collect_sys_info(&my_meta, g_ceph_context);
my_meta["addr"] = stringify(messenger->get_myaddr());
collect_metadata(&my_meta);
update_mon_metadata(rank, std::move(my_meta));
}
@ -1976,12 +1975,18 @@ void Monitor::lose_election(epoch_t epoch, set<int> &q, int l,
if (quorum_con_features & CEPH_FEATURE_MON_METADATA) {
Metadata sys_info;
collect_sys_info(&sys_info, g_ceph_context);
collect_metadata(&sys_info);
messenger->send_message(new MMonMetadata(sys_info),
monmap->get_inst(get_leader()));
}
}
void Monitor::collect_metadata(Metadata *m)
{
collect_sys_info(m, g_ceph_context);
(*m)["addr"] = stringify(messenger->get_myaddr());
}
void Monitor::finish_election()
{
apply_quorum_to_compatset_features();

View File

@ -876,6 +876,7 @@ public:
int write_default_keyring(bufferlist& bl);
void extract_save_mon_key(KeyRing& keyring);
void collect_metadata(Metadata *m);
void update_mon_metadata(int from, Metadata&& m);
int load_metadata(map<int, Metadata>& m);
void count_metadata(const string& field, Formatter *f);