mon/MonmapMonitor: clean up empty created stamp in monmap

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>
This commit is contained in:
Sage Weil 2019-04-02 16:50:08 -05:00
parent b8757a878f
commit 3046d17f61
2 changed files with 37 additions and 0 deletions

View File

@ -928,3 +928,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();
}
}

View File

@ -72,6 +72,8 @@ class MonmapMonitor : public PaxosService {
void check_sub(Subscription *sub);
void tick() override;
private:
void check_subs();
bufferlist monmap_bl;