]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr: add killpoint for sqlite3 database setup
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 17 Apr 2024 19:44:30 +0000 (15:44 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Mon, 29 Apr 2024 16:22:26 +0000 (12:22 -0400)
To catch unintentional autocommit by sqlite3.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/pybind/mgr/mgr_module.py

index d56aac09b71b5886a8fee4b4561dbbce4276a3b1..5ea2435774c16399eb069af821c7a64d6fe34dce 100644 (file)
@@ -18,6 +18,7 @@ import subprocess
 import threading
 from collections import defaultdict
 from enum import IntEnum, Enum
+import os
 import rados
 import re
 import socket
@@ -875,6 +876,8 @@ class MgrStandbyModule(ceph_module.BaseMgrStandbyModule, MgrModuleLoggingMixin):
                                  'warning', '']))
         cls.MODULE_OPTIONS.append(
             Option(name='log_to_file', type='bool', default=False, runtime=True))
+        cls.MODULE_OPTIONS.append(
+            Option(name='sqlite3_killpoint', level=OptionLevel.DEV, type='int', default=0, runtime=True))
         if not [x for x in cls.MODULE_OPTIONS if x['name'] == 'log_to_cluster']:
             cls.MODULE_OPTIONS.append(
                 Option(name='log_to_cluster', type='bool', default=False,
@@ -1077,6 +1080,8 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
                                  'warning', '']))
         cls.MODULE_OPTIONS.append(
             Option(name='log_to_file', type='bool', default=False, runtime=True))
+        cls.MODULE_OPTIONS.append(
+            Option(name='sqlite3_killpoint', level=OptionLevel.DEV, type='int', default=0, runtime=True))
         if not [x for x in cls.MODULE_OPTIONS if x['name'] == 'log_to_cluster']:
             cls.MODULE_OPTIONS.append(
                 Option(name='log_to_cluster', type='bool', default=False,
@@ -1244,13 +1249,20 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
         SELECT value FROM MgrModuleKV WHERE key = '__version';
         """
 
+        kv = self.get_module_option('sqlite3_killpoint')
         with db:
             self.create_skeleton_schema(db)
+            if kv == 1:
+                os._exit(120)
             cur = db.execute(SQL)
             row = cur.fetchone()
             self.maybe_upgrade(db, int(row['value']))
             assert cur.fetchone() is None
             cur.close()
+            if kv == 2:
+                os._exit(120)
+        if kv == 3:
+            os._exit(120)
 
     def configure_db(self, db: sqlite3.Connection) -> None:
         db.execute('PRAGMA FOREIGN_KEYS = 1')