From: Kefu Chai Date: Wed, 10 Feb 2021 07:29:33 +0000 (+0800) Subject: mgr/crash: add crash to flake8 test X-Git-Tag: v17.1.0~2944^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=22cfcc23d6681fc54e90c7468e2d5438671b53be;p=ceph.git mgr/crash: add crash to flake8 test Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/crash/__init__.py b/src/pybind/mgr/crash/__init__.py index 8f210ac9247..ee85dc9d376 100644 --- a/src/pybind/mgr/crash/__init__.py +++ b/src/pybind/mgr/crash/__init__.py @@ -1 +1,2 @@ +# flake8: noqa from .module import Module diff --git a/src/pybind/mgr/crash/module.py b/src/pybind/mgr/crash/module.py index d386d2529a9..1cbe2026fb9 100644 --- a/src/pybind/mgr/crash/module.py +++ b/src/pybind/mgr/crash/module.py @@ -42,13 +42,13 @@ class Module(MgrModule): Option( name='warn_recent_interval', type='secs', - default=60*60*24*14, + default=60 * 60 * 24 * 14, desc='time interval in which to warn about recent crashes', runtime=True), Option( name='retain_interval', type='secs', - default=60*60*24 * 365, + default=60 * 60 * 24 * 365, desc='how long to retain crashes before pruning them', runtime=True), ] @@ -97,8 +97,8 @@ class Module(MgrModule): seconds=self.warn_recent_interval) recent = { crashid: crash for crashid, crash in self.crashes.items() - if (self.time_from_string(cast(str, crash['timestamp'])) > cutoff and - 'archived' not in crash) + if (self.time_from_string(cast(str, crash['timestamp'])) > cutoff + and 'archived' not in crash) } num = len(recent) health_checks: Dict[str, Dict[str, Union[int, str, List[str]]]] = {} @@ -284,7 +284,7 @@ class Module(MgrModule): """ Remove crashes older than days """ - self._prune(keep * 60*60*24) + self._prune(keep * datetime.timedelta(days=1).total_seconds()) return 0, '', '' def _prune(self, seconds: float) -> None: diff --git a/src/pybind/mgr/tox.ini b/src/pybind/mgr/tox.ini index 10c66b3a6a2..dd7e1a43d63 100644 --- a/src/pybind/mgr/tox.ini +++ b/src/pybind/mgr/tox.ini @@ -116,6 +116,7 @@ deps = flake8 modules = cephadm + crash devicehealth hello orchestrator