From: Sage Weil Date: Tue, 10 Mar 2020 14:01:15 +0000 (-0500) Subject: mgr/cephadm: reconfigure ceph daemons when monmap changes X-Git-Tag: v15.1.1~22^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F33855%2Fhead;p=ceph.git mgr/cephadm: reconfigure ceph daemons when monmap changes This keeps ceph.conf fresh. Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 6f3851ee7d7d..4a86b6a084fe 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -61,6 +61,7 @@ DEFAULT_SSH_CONFIG = ('Host *\n' 'UserKnownHostsFile /dev/null\n') DATEFMT = '%Y-%m-%dT%H:%M:%S.%f' +CEPH_DATEFMT = '%Y-%m-%dT%H:%M:%S.%fZ' HOST_CACHE_PREFIX = "host." SPEC_STORE_PREFIX = "spec." @@ -2267,6 +2268,13 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): return r def _check_daemons(self): + # get monmap mtime so we can refresh configs when mons change + monmap = self.get('mon_map') + last_monmap: Optional[datetime.datetime] = datetime.datetime.strptime( + monmap['modified'], CEPH_DATEFMT) + if last_monmap and last_monmap > datetime.datetime.utcnow(): + last_monmap = None # just in case clocks are skewed + daemons = self.cache.get_daemons() grafanas = [] # type: List[orchestrator.DaemonDescription] for dd in daemons: @@ -2287,11 +2295,23 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): dd.hostname, dd.name()) if last_deps is None: last_deps = [] - if last_deps != deps: + reconfig = False + if not last_config: + self.log.info('Reconfiguring %s (unknown last config time)...'% ( + dd.name())) + reconfig = True + elif last_deps != deps: self.log.debug('%s deps %s -> %s' % (dd.name(), last_deps, deps)) self.log.info('Reconfiguring %s (dependencies changed)...' % ( dd.name())) + reconfig = True + elif last_monmap and \ + last_monmap > last_config and \ + dd.daemon_type in CEPH_TYPES: + self.log.info('Reconfiguring %s (monmap changed)...' % dd.name()) + reconfig = True + if reconfig: self._create_daemon(dd.daemon_type, dd.daemon_id, dd.hostname, reconfig=True)