Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgr/rbd_support: store global schedule without localized prefix #37864

Merged
merged 2 commits into from Oct 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/pybind/mgr/rbd_support/schedule.py
Expand Up @@ -343,8 +343,20 @@ def __len__(self):

def load(self, namespace_validator=None, image_validator=None):

schedule_cfg = self.handler.module.get_localized_module_option(
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.
if not schedule_cfg:
schedule_cfg = self.handler.module.get_localized_module_option(
self.handler.MODULE_OPTION_NAME, '')
if schedule_cfg:
self.handler.module.set_module_option(
self.handler.MODULE_OPTION_NAME, schedule_cfg)
self.handler.module.set_localized_module_option(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: perhaps put this under the if clause at line 354 after moving it to the non-localized module options. There is technically a possibility of a MGR crash that will leave the old config under the localized section, but it seems unlikely enough and eventually we can remove all this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally put this out of the if clause, so it always had a chance to clean the old option. Consider a case when an old localized option exists for both mgr.x and mgr.y (mgr/rbd_support/x/mirror_snapshot_schedule and mgr/rbd_support/y/mirror_snapshot_schedule). After upgrade the active mgr.x "fixes" mgr/rbd_support/x/mirror_snapshot_schedule making it mgr/rbd_support/mirror_snapshot_schedule. Then mgr.y becomes active, and if it is under if clause it will not remove mgr/rbd_support/y/mirror_snapshot_schedule because mgr/rbd_support/mirror_snapshot_schedule exists. And then if the user decides to remove the global schedule (mgr/rbd_support/mirror_snapshot_schedule) the mgr.y will mysteriously reuse mgr/rbd_support/y/mirror_snapshot_schedule.

self.handler.MODULE_OPTION_NAME, None)

if schedule_cfg:
try:
level_spec = LevelSpec.make_global()
Expand Down Expand Up @@ -420,8 +432,8 @@ def load_from_pool(self, ioctx, namespace_validator, image_validator):

def save(self, level_spec, schedule):
if level_spec.is_global():
schedule_cfg = schedule and schedule.to_json() or ''
self.handler.module.set_localized_module_option(
schedule_cfg = schedule and schedule.to_json() or None
self.handler.module.set_module_option(
self.handler.MODULE_OPTION_NAME, schedule_cfg)
return

Expand Down