]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/rbd_support: remove localized schedule option during module startup
authorRamana Raja <rraja@redhat.com>
Wed, 14 Dec 2022 05:09:37 +0000 (00:09 -0500)
committerRamana Raja <rraja@redhat.com>
Tue, 20 Dec 2022 16:29:02 +0000 (11:29 -0500)
The localized schedule option was removed during every load of a
scheduler handler. This occured multiple times during a mgr process's
lifespan. Instead, remove the localized schedule module option when the
rbd_support module starts up.

Fixes: https://tracker.ceph.com/issues/57726
Signed-off-by: Ramana Raja <rraja@redhat.com>
src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py
src/pybind/mgr/rbd_support/schedule.py
src/pybind/mgr/rbd_support/trash_purge_schedule.py

index 47efa57e82c8c3618e010a0a83f2834924fa2268..d3897cc67203a01473ef43fb663bd2332b5467ee 100644 (file)
@@ -369,15 +369,13 @@ class MirrorSnapshotScheduleHandler:
         self.queue: Dict[str, List[ImageSpec]] = {}
         # pool_id => {namespace => image_id}
         self.images: Dict[str, Dict[str, Dict[str, str]]] = {}
+        self.schedules = Schedules(self)
         self.refresh_images()
         self.log.debug("MirrorSnapshotScheduleHandler: queue is initialized")
 
     def load_schedules(self) -> None:
         self.log.info("MirrorSnapshotScheduleHandler: load_schedules")
-
-        schedules = Schedules(self)
-        schedules.load(namespace_validator, image_validator)
-        self.schedules = schedules
+        self.schedules.load(namespace_validator, image_validator)
 
     def refresh_images(self) -> float:
         elapsed = (datetime.now() - self.last_refresh_images).total_seconds()
index a91309c98c91e66c61542d879a78841e7bf4eeae..7a24d58ce773230d7c94b2f4a582b9bd5d940da3 100644 (file)
@@ -378,18 +378,10 @@ class Schedules:
         self.level_specs: Dict[str, LevelSpec] = {}
         self.schedules: Dict[str, Schedule] = {}
 
-    def __len__(self) -> int:
-        return len(self.schedules)
-
-    def load(self,
-             namespace_validator: Optional[Callable] = None,
-             image_validator: Optional[Callable] = None) -> None:
-
-        schedule_cfg = self.handler.module.get_module_option(
-            self.handler.MODULE_OPTION_NAME, '')
-
         # Previous versions incorrectly stored the global config in
         # the localized module option. Check the config is here and fix it.
+        schedule_cfg = self.handler.module.get_module_option(
+            self.handler.MODULE_OPTION_NAME, '')
         if not schedule_cfg:
             schedule_cfg = self.handler.module.get_localized_module_option(
                 self.handler.MODULE_OPTION_NAME, '')
@@ -399,6 +391,17 @@ class Schedules:
         self.handler.module.set_localized_module_option(
             self.handler.MODULE_OPTION_NAME, None)
 
+    def __len__(self) -> int:
+        return len(self.schedules)
+
+    def load(self,
+             namespace_validator: Optional[Callable] = None,
+             image_validator: Optional[Callable] = None) -> None:
+        self.level_specs = {}
+        self.schedules = {}
+
+        schedule_cfg = self.handler.module.get_module_option(
+            self.handler.MODULE_OPTION_NAME, '')
         if schedule_cfg:
             try:
                 level_spec = LevelSpec.make_global()
index e12fec457320624c9ceeacf235096859c760c6a2..ca1f111e66c4f0d912036b9cc005a07efd244002 100644 (file)
@@ -62,15 +62,13 @@ class TrashPurgeScheduleHandler:
         self.queue: Dict[str, List[Tuple[str, str]]] = {}
         # pool_id => {namespace => pool_name}
         self.pools: Dict[str, Dict[str, str]] = {}
+        self.schedules = Schedules(self)
         self.refresh_pools()
         self.log.debug("TrashPurgeScheduleHandler: queue is initialized")
 
     def load_schedules(self) -> None:
         self.log.info("TrashPurgeScheduleHandler: load_schedules")
-
-        schedules = Schedules(self)
-        schedules.load()
-        self.schedules = schedules
+        self.schedules.load()
 
     def refresh_pools(self) -> float:
         elapsed = (datetime.now() - self.last_refresh_pools).total_seconds()