From 2a2b3c2a8a2f0ef61a2ae5c09f0a649a976650f0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 12 Jul 2019 16:23:03 -0500 Subject: [PATCH] mgr/crash: add 'crash archive ', 'crash archive-all' commands Signed-off-by: Sage Weil (cherry picked from commit 31f650cb2049995faa03288e22591d967fd8a14d) --- src/pybind/mgr/crash/module.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/pybind/mgr/crash/module.py b/src/pybind/mgr/crash/module.py index 3a95e1085d1de..7330cad5ffb92 100644 --- a/src/pybind/mgr/crash/module.py +++ b/src/pybind/mgr/crash/module.py @@ -112,6 +112,26 @@ class Module(MgrModule): return 0, '', '' + def do_archive(self, cmd, inbuf): + crashid = cmd['id'] + key = 'crash/%s' % crashid + val = self.get_store(key) + if not val: + return errno.EINVAL, '', 'crash info: %s not found' % crashid + m = json.loads(val) + if not m.get('archived', None): + m['archived'] = str(datetime.datetime.utcnow()) + self.set_store(key, json.dumps(m)) + return 0, '', '' + + def do_archive_all(self, cmd, inbuf): + for key, m in self.timestamp_filter(lambda ts: True): + if not m.get('archived', None): + m['archived'] = str(datetime.datetime.utcnow()) + self.set_store(key, json.dumps(m)) + return 0, '', '' + + def do_stat(self, cmd, inbuf): # age in days for reporting, ordered smallest first bins = [1, 3, 7] @@ -224,4 +244,16 @@ class Module(MgrModule): 'perm': 'r', 'handler': do_json_report, }, + { + 'cmd': 'crash archive name=id,type=CephString', + 'desc': 'Acknowledge a crash and silence health warning(s)', + 'perm': 'w', + 'handler': do_archive, + }, + { + 'cmd': 'crash archive-all', + 'desc': 'Acknowledge all new crashes and silence health warning(s)', + 'perm': 'w', + 'handler': do_archive_all, + }, ] -- 2.39.5