]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonmapMonitor: clean up empty created stamp in monmap 27399/head
authorSage Weil <sage@redhat.com>
Tue, 2 Apr 2019 21:50:08 +0000 (16:50 -0500)
committerSage Weil <sage@redhat.com>
Fri, 5 Apr 2019 13:40:22 +0000 (08:40 -0500)
Some old clusters have an empty created timestamp.  This is mostly
harmless, but it is confusing/wrong, and it does currently break the
telemetry module with errors like

 ValueError: time data '0.000000' does not match format '%Y-%m-%d %H:%M:%S.%f'

from 'ceph telemetry show'.

If we detect an empty created stamp, look at old monmap and use the oldest
modified stamp we can find.

Fixes: http://tracker.ceph.com/issues/39085
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 3046d17f61d1fa11fe2f35f7cfe9428312a78593)

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

index 9298f24421120a69f4e9ad3b3fd0558d8f9532ec..800da05ad94d72dbdbc464b87f53ec7d35ecce94 100644 (file)
@@ -911,3 +911,38 @@ void MonmapMonitor::check_sub(Subscription *sub)
     }
   }
 }
+
+void MonmapMonitor::tick()
+{
+  if (!is_active() ||
+      !mon->is_leader()) {
+    return;
+  }
+
+  if (mon->monmap->created.is_zero()) {
+    dout(10) << __func__ << " detected empty created stamp" << dendl;
+    utime_t ctime;
+    for (version_t v = 1; v <= get_last_committed(); v++) {
+      bufferlist bl;
+      int r = get_version(v, bl);
+      if (r < 0) {
+       continue;
+      }
+      MonMap m;
+      auto p = bl.cbegin();
+      decode(m, p);
+      if (!m.last_changed.is_zero()) {
+       dout(10) << __func__ << " first monmap with last_changed is "
+                << v << " with " << m.last_changed << dendl;
+       ctime = m.last_changed;
+       break;
+      }
+    }
+    if (ctime.is_zero()) {
+      ctime = ceph_clock_now();
+    }
+    dout(10) << __func__ << " updating created stamp to " << ctime << dendl;
+    pending_map.created = ctime;
+    propose_pending();
+  }
+}
index ced31e8d3e171055bfa3292e7f559466a7ee0cf8..fc0bfdbde229d8bcf3695144398ad5ba95f9dc1c 100644 (file)
@@ -72,6 +72,8 @@ class MonmapMonitor : public PaxosService {
 
   void check_sub(Subscription *sub);
 
+  void tick() override;
+
 private:
   void check_subs();
   bufferlist monmap_bl;