]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: track age of service metadata
authorSage Weil <sage@redhat.com>
Mon, 23 Dec 2019 19:19:58 +0000 (13:19 -0600)
committerSage Weil <sage@redhat.com>
Fri, 24 Jan 2020 14:54:20 +0000 (08:54 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/cephadm/module.py

index 3d055d475f53af57dc867110436c2d04321f234f..d452eb3685700d9ad337abb2e5222f8c3db6a9f0 100644 (file)
@@ -12,6 +12,7 @@ except ImportError:
     pass  # just for type checking
 
 
+import datetime
 import six
 import os
 import random
@@ -47,6 +48,8 @@ DEFAULT_SSH_CONFIG = ('Host *\n'
                       'StrictHostKeyChecking no\n'
                       'UserKnownHostsFile /dev/null\n')
 
+DATEFMT = '%Y-%m-%dT%H:%M:%S.%f'
+
 # for py2 compat
 try:
     from tempfile import TemporaryDirectory # py3
@@ -1076,6 +1079,8 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
         out, err, code = self._run_cephadm(
             host, 'mon', 'ls', [], no_fsid=True)
         data = json.loads(''.join(out))
+        for d in data:
+            d['last_refresh'] = datetime.datetime.utcnow().strftime(DATEFMT)
         self.log.debug('Refreshed host %s services: %s' % (host, data))
         self.service_cache[host] = orchestrator.OutdatableData(data)
         return host, data
@@ -1117,6 +1122,8 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
                         continue
                     self.log.debug('including %s %s' % (host, d))
                     sd = orchestrator.ServiceDescription()
+                    sd.last_refresh = datetime.datetime.strptime(
+                        d.get('last_refresh'), DATEFMT)
                     sd.service_type = d['name'].split('.')[0]
                     if service_type and service_type != sd.service_type:
                         continue