From: Sage Weil Date: Wed, 20 Aug 2014 15:59:46 +0000 (-0700) Subject: mon: add a cluster fingerprint X-Git-Tag: v0.80.6~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ebcdeb4cfe201dd0c630386226f9970650689ccf;p=ceph.git mon: add a cluster fingerprint Generate it on cluster creations with the initial monmap. Include it in the report. Provide no way for this uuid to be fed in to the cluster (intentionally or not) so that it can be assumed to be a truly unique identifier for the cluster. Signed-off-by: Sage Weil (cherry picked from commit 675b0042eff0ad5e1453838410210b1206c39004) --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index c58e9894a3a..ed6488f7330 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -621,6 +621,21 @@ void Monitor::init_paxos() void Monitor::refresh_from_paxos(bool *need_bootstrap) { dout(10) << __func__ << dendl; + + bufferlist bl; + int r = store->get(MONITOR_NAME, "cluster_fingerprint", bl); + if (r >= 0) { + try { + bufferlist::iterator p = bl.begin(); + ::decode(fingerprint, p); + } + catch (buffer::error& e) { + dout(10) << __func__ << " failed to decode cluster_fingerprint" << dendl; + } + } else { + dout(10) << __func__ << " no cluster_fingerprint" << dendl; + } + for (int i = 0; i < PAXOS_NUM; ++i) { paxos_service[i]->refresh(need_bootstrap); } @@ -2393,6 +2408,7 @@ void Monitor::handle_command(MMonCommand *m) if (!f) f.reset(new_formatter("json-pretty")); f->open_object_section("report"); + f->dump_stream("cluster_fingerprint") << fingerprint; f->dump_string("version", ceph_version_to_str()); f->dump_string("commit", git_version_to_str()); f->dump_stream("timestamp") << ceph_clock_now(NULL); @@ -3851,6 +3867,17 @@ void Monitor::tick() new_tick(); } +void Monitor::prepare_new_fingerprint(MonitorDBStore::Transaction *t) +{ + uuid_d nf; + nf.generate_random(); + dout(10) << __func__ << " proposing cluster_fingerprint " << nf << dendl; + + bufferlist bl; + ::encode(nf, bl); + t->put(MONITOR_NAME, "cluster_fingerprint", bl); +} + int Monitor::check_fsid() { if (!store->exists(MONITOR_NAME, "cluster_uuid")) diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 59292ec46a1..42e148ee543 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -128,6 +128,7 @@ public: void unregister_cluster_logger(); MonMap *monmap; + uuid_d fingerprint; set extra_probe_peers; @@ -190,6 +191,8 @@ public: const utime_t &get_leader_since() const; + void prepare_new_fingerprint(MonitorDBStore::Transaction *t); + // -- elector -- private: Paxos *paxos; diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 5940724925b..3890704e852 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -97,6 +97,11 @@ void MonmapMonitor::encode_pending(MonitorDBStore::Transaction *t) put_version(t, pending_map.epoch, bl); put_last_committed(t, pending_map.epoch); + + // generate a cluster fingerprint, too? + if (pending_map.epoch == 1) { + mon->prepare_new_fingerprint(t); + } } void MonmapMonitor::on_active()