]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: Fix clone uid/gid mismatch 44800/head
authorKotresh HR <khiremat@redhat.com>
Thu, 10 Feb 2022 05:34:41 +0000 (11:04 +0530)
committerKotresh HR <khiremat@redhat.com>
Mon, 28 Feb 2022 11:56:14 +0000 (17:26 +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>
(cherry picked from commit b3c9e6b50cf4264538e4c41d19e7ebb8b2900c3a)

src/pybind/mgr/volumes/fs/async_cloner.py

index df3cb93582e9199e3c31fc899ee225ab04a11025..802a43f413b4072c254b1d58d8dae50cf73e0a56 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
 
@@ -186,18 +186,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: