From 377840a746e4d47b77e24648b06f53f4a52315c1 Mon Sep 17 00:00:00 2001 From: Ramana Raja Date: Wed, 14 Dec 2022 00:09:37 -0500 Subject: [PATCH] mgr/rbd_support: remove localized schedule option during module startup 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 --- .../rbd_support/mirror_snapshot_schedule.py | 6 ++--- src/pybind/mgr/rbd_support/schedule.py | 23 +++++++++++-------- .../mgr/rbd_support/trash_purge_schedule.py | 6 ++--- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py b/src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py index 47efa57e82c..d3897cc6720 100644 --- a/src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py +++ b/src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py @@ -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() diff --git a/src/pybind/mgr/rbd_support/schedule.py b/src/pybind/mgr/rbd_support/schedule.py index a91309c98c9..7a24d58ce77 100644 --- a/src/pybind/mgr/rbd_support/schedule.py +++ b/src/pybind/mgr/rbd_support/schedule.py @@ -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() diff --git a/src/pybind/mgr/rbd_support/trash_purge_schedule.py b/src/pybind/mgr/rbd_support/trash_purge_schedule.py index e12fec45732..ca1f111e66c 100644 --- a/src/pybind/mgr/rbd_support/trash_purge_schedule.py +++ b/src/pybind/mgr/rbd_support/trash_purge_schedule.py @@ -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()