]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/ceph_volume_client: use cephfs mkdirs api 42161/head
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 2 Jul 2021 16:07:34 +0000 (09:07 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 2 Jul 2021 17:15:47 +0000 (10:15 -0700)
This _mkdir_p should never have worked as the first directory it tries
to stat/mkdir is "", the empty string. This causes an assertion in the
client. I'm not sure how this code ever functioned without causing
faults. They look like:

    2021-07-01 02:15:04.449 7f7612b5ab80  3 client.178735 statx enter (relpath  want 2047)

The assertion is caused by a C++ exception:

/usr/include/c++/8/string_view:172: constexpr const _CharT& std::basic_string_view<_CharT, _Traits>::operator[](std::basic_string_view<_CharT, _Traits>::size_type) const [with _CharT = char$_Traits = std::char_traits<char>; std::basic_string_view<_CharT, _Traits>::size_type = long unsigned int]: Assertion '__pos < this->_M_len' failed.
        Aborted (core dumped)

Where relpath is just the path passed to Client::stat.

This commit only applies to Pacific and older because master no longer
has this library.

Fixes: https://tracker.ceph.com/issues/51492
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 0fb05aea8a6e12c37a9b54641715a9a94ae1366f)

src/pybind/ceph_volume_client.py

index 7fc5e768a16115a97f0359bb7763604d8aa1fc49..e89b650cb0f18dbb9b10966517a3d3890e4b28d6 100644 (file)
@@ -608,7 +608,7 @@ class CephFSVolumeClient(object):
             raise ValueError("group ID cannot end with '{0}'.".format(
                 META_FILE_EXT))
         path = self._get_group_path(group_id)
-        self._mkdir_p(path, mode)
+        self.fs.mkdirs(path, mode)
 
     def destroy_group(self, group_id):
         path = self._get_group_path(group_id)
@@ -619,23 +619,6 @@ class CephFSVolumeClient(object):
         else:
             self.fs.rmdir(path)
 
-    def _mkdir_p(self, path, mode=0o755):
-        try:
-            self.fs.stat(path)
-        except cephfs.ObjectNotFound:
-            pass
-        else:
-            return
-
-        parts = path.split(os.path.sep)
-
-        for i in range(1, len(parts) + 1):
-            subpath = os.path.join(*parts[0:i])
-            try:
-                self.fs.stat(subpath)
-            except cephfs.ObjectNotFound:
-                self.fs.mkdir(subpath, mode)
-
     def create_volume(self, volume_path, size=None, data_isolated=False, namespace_isolated=True,
                       mode=0o755):
         """
@@ -653,7 +636,7 @@ class CephFSVolumeClient(object):
         path = self._get_path(volume_path)
         log.info("create_volume: {0}".format(path))
 
-        self._mkdir_p(path, mode)
+        self.fs.mkdirs(path, mode)
 
         if size is not None:
             self.fs.setxattr(path, 'ceph.quota.max_bytes', to_bytes(size), 0)
@@ -711,7 +694,7 @@ class CephFSVolumeClient(object):
 
         # Create the trash folder if it doesn't already exist
         trash = os.path.join(self.volume_prefix, "_deleting")
-        self._mkdir_p(trash)
+        self.fs.mkdirs(trash, 0o755)
 
         # We'll move it to here
         trashed_volume = os.path.join(trash, volume_path.volume_id)