From: Ramana Raja Date: Wed, 14 Dec 2022 05:09:37 +0000 (-0500) Subject: mgr/rbd_support: remove localized schedule option during module startup X-Git-Tag: v16.2.13~138^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=57c5850f59b91cce7547298667cc88795e1a7a8e;p=ceph.git 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 (cherry picked from commit 377840a746e4d47b77e24648b06f53f4a52315c1) Conflicts: 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 - Above conflicts were due to commit e4a16e2 ("mgr/rbd_support: add type annotation") not in pacific --- diff --git a/src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py b/src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py index 536ee3d16c9..af32a77aaad 100644 --- a/src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py +++ b/src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py @@ -342,15 +342,13 @@ class MirrorSnapshotScheduleHandler: def init_schedule_queue(self): self.queue = {} self.images = {} + self.schedules = Schedules(self) self.refresh_images() self.log.debug("MirrorSnapshotScheduleHandler: queue is initialized") def load_schedules(self): 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): 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 3063a086a41..167514bbbfa 100644 --- a/src/pybind/mgr/rbd_support/schedule.py +++ b/src/pybind/mgr/rbd_support/schedule.py @@ -338,16 +338,10 @@ class Schedules: self.level_specs = {} self.schedules = {} - def __len__(self): - return len(self.schedules) - - def load(self, namespace_validator=None, image_validator=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, '') @@ -357,6 +351,15 @@ class Schedules: self.handler.module.set_localized_module_option( self.handler.MODULE_OPTION_NAME, None) + def __len__(self): + return len(self.schedules) + + def load(self, namespace_validator=None, image_validator=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 bf5d8ae7081..df6221f53fb 100644 --- a/src/pybind/mgr/rbd_support/trash_purge_schedule.py +++ b/src/pybind/mgr/rbd_support/trash_purge_schedule.py @@ -63,15 +63,13 @@ class TrashPurgeScheduleHandler: def init_schedule_queue(self): self.queue = {} self.pools = {} + self.schedules = Schedules(self) self.refresh_pools() self.log.debug("TrashPurgeScheduleHandler: queue is initialized") def load_schedules(self): self.log.info("TrashPurgeScheduleHandler: load_schedules") - - schedules = Schedules(self) - schedules.load() - self.schedules = schedules + self.schedules.load() def refresh_pools(self): elapsed = (datetime.now() - self.last_refresh_pools).total_seconds()