]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/volumes: Fix clone uid/gid mismatch
authorKotresh HR <khiremat@redhat.com>
Thu, 10 Feb 2022 05:34:41 +0000 (11:04 +0530)
committerKotresh HR <khiremat@redhat.com>
Thu, 10 Feb 2022 09:46:22 +0000 (15:16 +0530)
This is the regression caused by commit 18b85c53a.
The 'set_attrs' function sets the uid/gid of the
group to the subvolume if uid/gid is not passed.
The attrs of the clone should match the source
snapshot. Hence, don't use the 'set_attrs'
function to set only the quota attrs for the
clone.

Fixes: https://tracker.ceph.com/issues/54066
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/pybind/mgr/volumes/fs/async_cloner.py

index 68ebb9e263a7f28769288d2c544b09df99350c4c..b319201011aa923c514afaf2b6b1fdef08be5633 100644 (file)
@@ -4,7 +4,7 @@ import time
 import errno
 import logging
 from contextlib import contextmanager
-from typing import Dict, Union
+from typing import Optional
 
 import cephfs
 from mgr_util import lock_timeout_log
@@ -187,18 +187,21 @@ def bulk_copy(fs_handle, source_path, dst_path, should_cancel):
         raise VolumeException(-errno.EINTR, "clone operation interrupted")
 
 def set_quota_on_clone(fs_handle, clone_volumes_pair):
-    attrs = {}  # type: Dict[str, Union[int, str, None]]
     src_path = clone_volumes_pair[1].snapshot_data_path(clone_volumes_pair[2])
     dst_path = clone_volumes_pair[0].path
+    quota = None # type: Optional[int]
     try:
-        attrs["quota"] = int(fs_handle.getxattr(src_path,
-                                                'ceph.quota.max_bytes'
-                                                ).decode('utf-8'))
+        quota = int(fs_handle.getxattr(src_path, 'ceph.quota.max_bytes').decode('utf-8'))
     except cephfs.NoData:
-        attrs["quota"] = None
+        pass
 
-    if attrs["quota"] is not None:
-        clone_volumes_pair[0].set_attrs(dst_path, attrs)
+    if quota is not None:
+        try:
+            fs_handle.setxattr(dst_path, 'ceph.quota.max_bytes', str(quota).encode('utf-8'), 0)
+        except cephfs.InvalidValue:
+            raise VolumeException(-errno.EINVAL, "invalid size specified: '{0}'".format(quota))
+        except cephfs.Error as e:
+             raise VolumeException(-e.args[0], e.args[1])
 
 def do_clone(fs_client, volspec, volname, groupname, subvolname, should_cancel):
     with open_volume_lockless(fs_client, volname) as fs_handle: