|
|
733bdf |
From 80b635be63902048622e6a6093cac5ae8a324643 Mon Sep 17 00:00:00 2001
|
|
|
733bdf |
From: Patrick Donnelly <pdonnell@redhat.com>
|
|
|
733bdf |
Date: Fri, 2 Jul 2021 09:07:34 -0700
|
|
|
733bdf |
Subject: [PATCH] pybind/ceph_volume_client: use cephfs mkdirs api
|
|
|
733bdf |
|
|
|
733bdf |
This _mkdir_p should never have worked as the first directory it tries
|
|
|
733bdf |
to stat/mkdir is "", the empty string. This causes an assertion in the
|
|
|
733bdf |
client. I'm not sure how this code ever functioned without causing
|
|
|
733bdf |
faults. They look like:
|
|
|
733bdf |
|
|
|
733bdf |
2021-07-01 02:15:04.449 7f7612b5ab80 3 client.178735 statx enter (relpath want 2047)
|
|
|
733bdf |
|
|
|
733bdf |
The assertion is caused by a C++ exception:
|
|
|
733bdf |
|
|
|
733bdf |
/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.
|
|
|
733bdf |
Aborted (core dumped)
|
|
|
733bdf |
|
|
|
733bdf |
Where relpath is just the path passed to Client::stat.
|
|
|
733bdf |
|
|
|
733bdf |
This commit only applies to Pacific and older because master no longer
|
|
|
733bdf |
has this library.
|
|
|
733bdf |
|
|
|
733bdf |
Fixes: https://tracker.ceph.com/issues/51492
|
|
|
733bdf |
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
|
|
|
733bdf |
(cherry picked from commit 0fb05aea8a6e12c37a9b54641715a9a94ae1366f)
|
|
|
733bdf |
---
|
|
|
733bdf |
src/pybind/ceph_volume_client.py | 23 +++--------------------
|
|
|
733bdf |
1 file changed, 3 insertions(+), 20 deletions(-)
|
|
|
733bdf |
|
|
|
733bdf |
diff --git a/src/pybind/ceph_volume_client.py b/src/pybind/ceph_volume_client.py
|
|
|
733bdf |
index b37d48ca260..1e5e192d80d 100644
|
|
|
733bdf |
--- a/src/pybind/ceph_volume_client.py
|
|
|
733bdf |
+++ b/src/pybind/ceph_volume_client.py
|
|
|
733bdf |
@@ -629,7 +629,7 @@ class CephFSVolumeClient(object):
|
|
|
733bdf |
raise ValueError("group ID cannot end with '{0}'.".format(
|
|
|
733bdf |
META_FILE_EXT))
|
|
|
733bdf |
path = self._get_group_path(group_id)
|
|
|
733bdf |
- self._mkdir_p(path, mode)
|
|
|
733bdf |
+ self.fs.mkdirs(path, mode)
|
|
|
733bdf |
|
|
|
733bdf |
def destroy_group(self, group_id):
|
|
|
733bdf |
path = self._get_group_path(group_id)
|
|
|
733bdf |
@@ -640,23 +640,6 @@ class CephFSVolumeClient(object):
|
|
|
733bdf |
else:
|
|
|
733bdf |
self.fs.rmdir(path)
|
|
|
733bdf |
|
|
|
733bdf |
- def _mkdir_p(self, path, mode=0o755):
|
|
|
733bdf |
- try:
|
|
|
733bdf |
- self.fs.stat(path)
|
|
|
733bdf |
- except cephfs.ObjectNotFound:
|
|
|
733bdf |
- pass
|
|
|
733bdf |
- else:
|
|
|
733bdf |
- return
|
|
|
733bdf |
-
|
|
|
733bdf |
- parts = path.split(os.path.sep)
|
|
|
733bdf |
-
|
|
|
733bdf |
- for i in range(1, len(parts) + 1):
|
|
|
733bdf |
- subpath = os.path.join(*parts[0:i])
|
|
|
733bdf |
- try:
|
|
|
733bdf |
- self.fs.stat(subpath)
|
|
|
733bdf |
- except cephfs.ObjectNotFound:
|
|
|
733bdf |
- self.fs.mkdir(subpath, mode)
|
|
|
733bdf |
-
|
|
|
733bdf |
def create_volume(self, volume_path, size=None, data_isolated=False, namespace_isolated=True,
|
|
|
733bdf |
mode=0o755):
|
|
|
733bdf |
"""
|
|
|
733bdf |
@@ -674,7 +657,7 @@ class CephFSVolumeClient(object):
|
|
|
733bdf |
path = self._get_path(volume_path)
|
|
|
733bdf |
log.info("create_volume: {0}".format(path))
|
|
|
733bdf |
|
|
|
733bdf |
- self._mkdir_p(path, mode)
|
|
|
733bdf |
+ self.fs.mkdirs(path, mode)
|
|
|
733bdf |
|
|
|
733bdf |
if size is not None:
|
|
|
733bdf |
self.fs.setxattr(path, 'ceph.quota.max_bytes', to_bytes(size), 0)
|
|
|
733bdf |
@@ -732,7 +715,7 @@ class CephFSVolumeClient(object):
|
|
|
733bdf |
|
|
|
733bdf |
# Create the trash folder if it doesn't already exist
|
|
|
733bdf |
trash = os.path.join(self.volume_prefix, "_deleting")
|
|
|
733bdf |
- self._mkdir_p(trash)
|
|
|
733bdf |
+ self.fs.mkdirs(trash, 0o755)
|
|
|
733bdf |
|
|
|
733bdf |
# We'll move it to here
|
|
|
733bdf |
trashed_volume = os.path.join(trash, volume_path.volume_id)
|
|
|
733bdf |
--
|
|
|
733bdf |
2.31.1
|
|
|
733bdf |
|