From: John Spray Date: Thu, 12 May 2016 14:49:23 +0000 (+0100) Subject: mon: fix 'mon metadata' for lone monitors X-Git-Tag: v10.2.3~15^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=828df3995430ce89fe9be40c6c19c44fb6f14752;p=ceph.git mon: fix 'mon metadata' for lone monitors Previously, writing to the store was only triggered when MMonMetadata was received from peers, so if you had a single mon then you would always get ENOENT from "mon metadata" Fixes: http://tracker.ceph.com/issues/15866 Signed-off-by: John Spray (cherry picked from commit 93ab00c77059e93b52ac4caa703e259944be1d1e) --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 590b2bcd8373..9ba323108825 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -1916,7 +1916,10 @@ void Monitor::win_election(epoch_t epoch, set& active, uint64_t features, do_health_to_clog_interval(); scrub_event_start(); } - collect_sys_info(&metadata[rank], g_ceph_context); + + Metadata my_meta; + collect_sys_info(&my_meta, g_ceph_context); + update_mon_metadata(rank, my_meta); } void Monitor::lose_election(epoch_t epoch, set &q, int l, uint64_t features) @@ -4431,7 +4434,7 @@ void Monitor::handle_mon_metadata(MonOpRequestRef op) void Monitor::update_mon_metadata(int from, const Metadata& m) { - metadata[from] = m; + pending_metadata[from] = m; bufferlist bl; int err = store->get(MONITOR_STORE_PREFIX, "last_metadata", bl); @@ -4439,12 +4442,12 @@ void Monitor::update_mon_metadata(int from, const Metadata& m) if (!err) { bufferlist::iterator iter = bl.begin(); ::decode(last_metadata, iter); - metadata.insert(last_metadata.begin(), last_metadata.end()); + pending_metadata.insert(last_metadata.begin(), last_metadata.end()); } MonitorDBStore::TransactionRef t = paxos->get_pending_transaction(); bl.clear(); - ::encode(metadata, bl); + ::encode(pending_metadata, bl); t->put(MONITOR_STORE_PREFIX, "last_metadata", bl); paxos->trigger_propose(); } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index add1c3ed6760..fadd316658bb 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -717,7 +717,9 @@ public: void handle_mon_metadata(MonOpRequestRef op); int get_mon_metadata(int mon, Formatter *f, ostream& err); int print_nodes(Formatter *f, ostream& err); - map metadata; + + // Accumulate metadata across calls to update_mon_metadata + map pending_metadata; /** *