From 0c5804ab4e5eb284d127044c5e51fbc870f5727a Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Thu, 7 Dec 2023 14:01:42 +0530 Subject: mgr/volumes: conditionalize subvolume upgrade Signed-off-by: Milind Changire --- src/pybind/mgr/volumes/fs/operations/versions/__init__.py | 15 +++++++++++++++ .../volumes/fs/operations/versions/metadata_manager.py | 1 + 2 files changed, 16 insertions(+) (limited to 'src/pybind') diff --git a/src/pybind/mgr/volumes/fs/operations/versions/__init__.py b/src/pybind/mgr/volumes/fs/operations/versions/__init__.py index 6c96c457019..097620d7378 100644 --- a/src/pybind/mgr/volumes/fs/operations/versions/__init__.py +++ b/src/pybind/mgr/volumes/fs/operations/versions/__init__.py @@ -49,6 +49,18 @@ class SubvolumeLoader(object): def get_subvolume_object_max(self, mgr, fs, vol_spec, group, subvolname): return self._get_subvolume_version(self.max_version)(mgr, fs, vol_spec, group, subvolname) + def allow_subvolume_upgrade(self, subvolume): + asu = True + try: + opt = subvolume.metadata_mgr.get_global_option(MetadataManager.GLOBAL_META_KEY_ALLOW_SUBVOLUME_UPGRADE) + asu = False if opt == "0" else True + except MetadataMgrException: + # this key is injected for QA testing and will not be available in + # production + pass + + return asu + def upgrade_to_v2_subvolume(self, subvolume): # legacy mode subvolumes cannot be upgraded to v2 if subvolume.legacy_mode: @@ -58,6 +70,9 @@ class SubvolumeLoader(object): if version >= SubvolumeV2.version(): return + if not self.allow_subvolume_upgrade(subvolume): + return + v1_subvolume = self._get_subvolume_version(version)(subvolume.mgr, subvolume.fs, subvolume.vol_spec, subvolume.group, subvolume.subvolname) try: v1_subvolume.open(SubvolumeOpType.SNAP_LIST) diff --git a/src/pybind/mgr/volumes/fs/operations/versions/metadata_manager.py b/src/pybind/mgr/volumes/fs/operations/versions/metadata_manager.py index b33a2b48b77..610a61e6a4c 100644 --- a/src/pybind/mgr/volumes/fs/operations/versions/metadata_manager.py +++ b/src/pybind/mgr/volumes/fs/operations/versions/metadata_manager.py @@ -58,6 +58,7 @@ class MetadataManager(object): GLOBAL_META_KEY_TYPE = "type" GLOBAL_META_KEY_PATH = "path" GLOBAL_META_KEY_STATE = "state" + GLOBAL_META_KEY_ALLOW_SUBVOLUME_UPGRADE = "allow_subvolume_upgrade" CLONE_FAILURE_SECTION = "CLONE_FAILURE" CLONE_FAILURE_META_KEY_ERRNO = "errno" -- cgit v1.2.3