From: Melissa Li Date: Tue, 3 Aug 2021 17:50:26 +0000 (-0400) Subject: mgr/cephadm: refactor `_check_for_strays` to use `remove_health_warning` helper X-Git-Tag: v16.2.7~67^2~36 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f09e8d8775f3e4cb66d56da284d5c0b777f84d4c;p=ceph.git mgr/cephadm: refactor `_check_for_strays` to use `remove_health_warning` helper Fixes: https://tracker.ceph.com/issues/44414 Signed-off-by: Melissa Li (cherry picked from commit f42992a1ef8f7827155e377013cef6c9a8cba15b) --- diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index 73e43031882f..36b64f6d2062 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -493,8 +493,7 @@ class CephadmServe: self.log.debug('_check_for_strays') for k in ['CEPHADM_STRAY_HOST', 'CEPHADM_STRAY_DAEMON']: - if k in self.mgr.health_checks: - del self.mgr.health_checks[k] + self.mgr.remove_health_warning(k) if self.mgr.warn_on_stray_hosts or self.mgr.warn_on_stray_daemons: ls = self.mgr.list_servers() managed = self.mgr.cache.get_daemon_names() @@ -539,23 +538,9 @@ class CephadmServe: 'stray host %s has %d stray daemons: %s' % ( host, len(missing_names), missing_names)) if self.mgr.warn_on_stray_hosts and host_detail: - self.mgr.health_checks['CEPHADM_STRAY_HOST'] = { - 'severity': 'warning', - 'summary': '%d stray host(s) with %s daemon(s) ' - 'not managed by cephadm' % ( - len(host_detail), host_num_daemons), - 'count': len(host_detail), - 'detail': host_detail, - } + self.mgr.set_health_warning('CEPHADM_STRAY_HOST', f'{len(host_detail)} stray host(s) with {host_num_daemons} daemon(s) not managed by cephadm', len(host_detail), host_detail) if self.mgr.warn_on_stray_daemons and daemon_detail: - self.mgr.health_checks['CEPHADM_STRAY_DAEMON'] = { - 'severity': 'warning', - 'summary': '%d stray daemon(s) not managed by cephadm' % ( - len(daemon_detail)), - 'count': len(daemon_detail), - 'detail': daemon_detail, - } - self.mgr.set_health_checks(self.mgr.health_checks) + self.mgr.set_health_warning('CEPHADM_STRAY_DAEMON', f'{len(daemon_detail)} stray daemon(s) not managed by cephadm', len(daemon_detail), daemon_detail) def _apply_all_services(self) -> bool: r = False