]> 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>
Thu, 21 Aug 2014 18:14:46 +0000 (11:14 -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>
src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/MonmapMonitor.cc

index 1c75c74268c0d8747ef636926628f64b1c27a6a6..919e240ad7904aa7e2dbdb1919948c511a3244c6 100644 (file)
@@ -678,6 +678,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);
   }
@@ -2460,6 +2475,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);
@@ -3932,6 +3948,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 5c8671c465b9adc3859d4c6faa6c6b2bd3b4eeff..aa4212450b9a2ba5c949b54a6db4cba466ff99e5 100644 (file)
@@ -143,6 +143,7 @@ public:
   void unregister_cluster_logger();
 
   MonMap *monmap;
+  uuid_d fingerprint;
 
   set<entity_addr_t> extra_probe_peers;
 
@@ -205,6 +206,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()