]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add a cluster fingerprint
authorSage Weil <sage@redhat.com>
Wed, 20 Aug 2014 15:59:46 +0000 (08:59 -0700)
committerSage Weil <sage@redhat.com>
Wed, 27 Aug 2014 00:00:41 +0000 (17:00 -0700)
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 <sage@redhat.com>
(cherry picked from commit 675b0042eff0ad5e1453838410210b1206c39004)

src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/MonmapMonitor.cc

index c58e9894a3a8991ec78c0d053604540c0d2f57d9..ed6488f7330e45747b9934cb7d0dc6e180168048 100644 (file)
@@ -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"))
index 59292ec46a1d7879d89dda72f67c546411961445..42e148ee5434db169f14f7db020fb2575528aa0d 100644 (file)
@@ -128,6 +128,7 @@ public:
   void unregister_cluster_logger();
 
   MonMap *monmap;
+  uuid_d fingerprint;
 
   set<entity_addr_t> 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;
index 5940724925bae4c70d9c97af3af1bc6ae2b029bd..3890704e852dccf76d4cee75baa76902c13d9a38 100644 (file)
@@ -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()