]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: V2 Fix for test_subvolume_retain_snapshot_invalid_recreate
authorKotresh HR <khiremat@redhat.com>
Thu, 9 Jun 2022 08:00:59 +0000 (13:30 +0530)
committerKotresh HR <khiremat@redhat.com>
Mon, 1 Aug 2022 04:07:15 +0000 (09:37 +0530)
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py
src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py

index b499d242e3bf924ea6aff398554491c03ba4f2a8..aba8c90cf6703bfb8a92f61bd94b770cc200b9b1 100644 (file)
@@ -17,6 +17,7 @@ from ...fs_util import get_ancestor_xattr
 from ...exception import MetadataMgrException, VolumeException
 from .op_sm import SubvolumeOpSm
 from .auth_metadata import AuthMetadataManager
+from .subvolume_attrs import SubvolumeStates
 
 log = logging.getLogger(__name__)
 
@@ -112,7 +113,7 @@ class SubvolumeBase(object):
     @property
     def state(self):
         """ Subvolume state, one of SubvolumeStates """
-        raise NotImplementedError
+        return SubvolumeStates.from_value(self.metadata_mgr.get_global_option(MetadataManager.GLOBAL_META_KEY_STATE))
 
     @property
     def subvol_type(self):
@@ -282,7 +283,10 @@ class SubvolumeBase(object):
             self.metadata_mgr.refresh()
             log.debug("loaded subvolume '{0}'".format(self.subvolname))
             subvolpath = self.metadata_mgr.get_global_option(MetadataManager.GLOBAL_META_KEY_PATH)
-            if not self.legacy_mode and self.base_path.decode('utf-8') != str(Path(subvolpath).parent):
+            # subvolume with retained snapshots has empty path, don't mistake it for
+            # fabricated metadata.
+            if (not self.legacy_mode and self.state != SubvolumeStates.STATE_RETAINED and
+                self.base_path.decode('utf-8') != str(Path(subvolpath).parent)):
                 raise MetadataMgrException(-errno.ENOENT, 'fabricated .meta')
         except MetadataMgrException as me:
             if me.errno in (-errno.ENOENT, -errno.EINVAL) and not self.legacy_mode:
index f7b13f17c7739b940e1c2c044d77c0a37e6d48a7..9e772653ba52726de7e2038d5d65b393bc968af0 100644 (file)
@@ -673,7 +673,7 @@ class SubvolumeV1(SubvolumeBase, SubvolumeTemplate):
 
     @property
     def state(self):
-        return SubvolumeStates.from_value(self.metadata_mgr.get_global_option(MetadataManager.GLOBAL_META_KEY_STATE))
+        return super(SubvolumeV1, self).state
 
     @state.setter
     def state(self, val):