]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind: convert ceph errno to host-based errno
authorRishabh Dave <ridave@redhat.com>
Tue, 19 Aug 2025 18:40:09 +0000 (00:10 +0530)
committerRishabh Dave <ridave@redhat.com>
Sun, 31 Aug 2025 18:48:54 +0000 (00:18 +0530)
Fixes: https://tracker.ceph.com/issues/72401
Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/pybind/cephfs/cephfs.pyx
src/pybind/cephfs/types.pxd

index fb81732bea9829e09a6d6d7050c6c6d177863f7c..1afa4c056bb8e5e3f377a42e57f73338e1ba6be9 100644 (file)
@@ -229,9 +229,12 @@ cdef make_ex(ret, msg):
     """
     ret = abs(ret)
     if ret in errno_to_exception:
-        return errno_to_exception[ret](ret, msg)
+        e = errno_to_exception[ret](ret, msg)
     else:
-        return OSError(ret, msg)
+        e = OSError(ret, msg)
+
+    e.errno = ceph_to_hostos_errno(e.errno)
+    return e
 
 
 class DirEntry(namedtuple('DirEntry',
@@ -512,7 +515,8 @@ cdef class LibCephFS(object):
         with nogil:
             ret = ceph_create_from_rados(&self.cluster, rados_inst.cluster)
         if ret != 0:
-            raise Error("libcephfs_initialize failed with error code: %d" % ret)
+            ret = ceph_to_hostos_errno(ret)
+            raise Error(f"libcephfs_initialize failed with error code: {ret}")
         self.state = "configuring"
 
     NO_CONF_FILE = -1
@@ -541,7 +545,8 @@ cdef class LibCephFS(object):
         with nogil:
             ret = ceph_create(&self.cluster, <const char*>_auth_id)
         if ret != 0:
-            raise Error("libcephfs_initialize failed with error code: %d" % ret)
+            ret = ceph_to_hostos_errno(ret)
+            raise Error(f"libcephfs_initialize failed with error code: {ret}")
 
         self.state = "configuring"
         if conffile in (self.NO_CONF_FILE, None):
index cbe31cbf4ba8031b7a17b23edbf06badfb9987d9..afbeec6b597b93129610d3db702e303c9f5703f4 100644 (file)
@@ -55,3 +55,7 @@ ELSE:
             unsigned short int d_reclen
             unsigned char d_type
             char d_name[256]
+
+cdef extern from "../include/platform_errno.h":
+    ctypedef signed int int32_t;
+    int32_t ceph_to_hostos_errno(int32_t e)