]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: Fix clone uid/gid mismatch 45205/head
authorKotresh HR <khiremat@redhat.com>
Thu, 10 Feb 2022 05:34:41 +0000 (11:04 +0530)
committerKotresh HR <khiremat@redhat.com>
Wed, 16 Mar 2022 06:47:22 +0000 (12:17 +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 e99393558d6bc4e1f7bde2df0a02e26bafd941d2..810397031f52b22186b5e9bafe11b5350d5765c1 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])
 
     quota_files = None # type: Optional[int]
     try: