From: Sage Weil Date: Mon, 23 Dec 2019 19:19:58 +0000 (-0600) Subject: mgr/cephadm: track age of service metadata X-Git-Tag: v15.1.0~64^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=77a1272b3c9fcdfb407f2be2b2fd832006f4440e;p=ceph.git mgr/cephadm: track age of service metadata Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 3d055d475f53..d452eb368570 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -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