]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/crash: add 'crash archive <id>', 'crash archive-all' commands
authorSage Weil <sage@redhat.com>
Fri, 12 Jul 2019 21:23:03 +0000 (16:23 -0500)
committerSage Weil <sage@redhat.com>
Fri, 15 Nov 2019 14:33:44 +0000 (08:33 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 31f650cb2049995faa03288e22591d967fd8a14d)

src/pybind/mgr/crash/module.py

index 3a95e1085d1de623503441418356f4d1d998b65f..7330cad5ffb92b4fae8540fb686fec94400cb78e 100644 (file)
@@ -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,
+        },
     ]