mgr/volumes: handle idempotent subvolume marks

Fixes: https://tracker.ceph.com/issues/47154
Signed-off-by: Venky Shankar <vshankar@redhat.com>
This commit is contained in:
Venky Shankar 2020-08-25 02:57:50 -04:00 committed by Shyamsundar Ranganathan
parent 88cffe6ea9
commit 2f5eed200a
2 changed files with 6 additions and 10 deletions

View File

@ -57,13 +57,11 @@ class SubvolumeV1(SubvolumeBase, SubvolumeTemplate):
def mark_subvolume(self):
# set subvolume attr, on subvolume root, marking it as a CephFS subvolume
# subvolume root is where snapshots would be taken, and hence is the <uuid> dir for v1 subvolumes
xattr_val = 1
try:
self.fs.setxattr(self.path, 'ceph.dir.subvolume', str(xattr_val).encode('utf-8'), os.XATTR_CREATE)
except cephfs.ObjectExists:
return
# MDS treats this as a noop for already marked subvolume
self.fs.setxattr(self.path, 'ceph.dir.subvolume', b'1', 0)
except cephfs.InvalidValue as e:
raise VolumeException(-errno.EINVAL, "invalid value specified for ceph.dir.subvolume: '{0}'".format(xattr_val))
raise VolumeException(-errno.EINVAL, "invalid value specified for ceph.dir.subvolume")
except cephfs.Error as e:
raise VolumeException(-e.args[0], e.args[1])

View File

@ -96,13 +96,11 @@ class SubvolumeV2(SubvolumeV1):
def mark_subvolume(self):
# set subvolume attr, on subvolume root, marking it as a CephFS subvolume
# subvolume root is where snapshots would be taken, and hence is the base_path for v2 subvolumes
xattr_val = 1
try:
self.fs.setxattr(self.base_path, 'ceph.dir.subvolume', str(xattr_val).encode('utf-8'), os.XATTR_CREATE)
except cephfs.ObjectExists:
return
# MDS treats this as a noop for already marked subvolume
self.fs.setxattr(self.base_path, 'ceph.dir.subvolume', b'1', 0)
except cephfs.InvalidValue as e:
raise VolumeException(-errno.EINVAL, "invalid value specified for ceph.dir.subvolume: '{0}'".format(xattr_val))
raise VolumeException(-errno.EINVAL, "invalid value specified for ceph.dir.subvolume")
except cephfs.Error as e:
raise VolumeException(-e.args[0], e.args[1])