]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: handle exceptions for cephfs_path_is_dir()
authorDhairya Parmar <dparmar@redhat.com>
Tue, 11 Apr 2023 10:09:00 +0000 (15:39 +0530)
committerDhairya Parmar <dparmar@redhat.com>
Tue, 2 May 2023 10:20:20 +0000 (15:50 +0530)
in create_cephfs_export()

Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
(cherry picked from commit d759fe4103174d412cc1ba317390383b299a7d35)

src/pybind/mgr/nfs/export.py

index eb8452f011cc871a67f20af682ee963c961f8e11..6296acdd14f3e6baea7bfc3c394d40dd2f2a1d52 100644 (file)
@@ -13,6 +13,7 @@ from typing import (
     Set,
     cast)
 from os.path import normpath
+import cephfs
 
 from rados import TimedOut, ObjectNotFound, Rados, LIBRADOS_ALL_NSPACES
 
@@ -20,7 +21,7 @@ from orchestrator import NoOrchestrator
 from mgr_module import NFS_POOL_NAME as POOL_NAME, NFS_GANESHA_SUPPORTED_FSALS
 
 from .export_utils import GaneshaConfParser, Export, RawBlock, CephFSFSAL, RGWFSAL
-from .exception import NFSException, NFSInvalidOperation, FSNotFound
+from .exception import NFSException, NFSInvalidOperation, FSNotFound, NFSObjectNotFound
 from .utils import (
     CONF_PREFIX,
     EXPORT_PREFIX,
@@ -29,7 +30,7 @@ from .utils import (
     conf_obj_name,
     available_clusters,
     check_fs,
-    restart_nfs_service, check_cephfs_path)
+    restart_nfs_service, cephfs_path_is_dir)
 
 if TYPE_CHECKING:
     from nfs.module import Module
@@ -632,7 +633,14 @@ class ExportMgr:
                              clients: list = [],
                              sectype: Optional[List[str]] = None) -> Tuple[int, str, str]:
 
-        check_cephfs_path(self.mgr, fs_name, path)
+        try:
+            cephfs_path_is_dir(self.mgr, fs_name, path)
+        except NotADirectoryError:
+            raise NFSException(f"path {path} is not a dir", -errno.ENOTDIR)
+        except cephfs.ObjectNotFound:
+            raise NFSObjectNotFound(f"path {path} does not exist")
+        except cephfs.Error as e:
+            raise NFSException(e.args[1], -e.args[0])
 
         pseudo_path = normalize_path(pseudo_path)