From: Dhairya Parmar Date: Tue, 11 Apr 2023 10:09:00 +0000 (+0530) Subject: mgr/nfs: handle exceptions for cephfs_path_is_dir() X-Git-Tag: v19.0.0~1313^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d759fe4103174d412cc1ba317390383b299a7d35;p=ceph.git mgr/nfs: handle exceptions for cephfs_path_is_dir() in create_cephfs_export() Signed-off-by: Dhairya Parmar --- diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index 935b12464e7b..5887c898fef9 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -12,6 +12,7 @@ from typing import ( Set, cast) from os.path import normpath +import cephfs from rados import TimedOut, ObjectNotFound, Rados, LIBRADOS_ALL_NSPACES @@ -26,7 +27,7 @@ from .ganesha_conf import ( RGWFSAL, RawBlock, format_block) -from .exception import NFSException, NFSInvalidOperation, FSNotFound +from .exception import NFSException, NFSInvalidOperation, FSNotFound, NFSObjectNotFound from .utils import ( CONF_PREFIX, EXPORT_PREFIX, @@ -36,7 +37,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 @@ -659,7 +660,14 @@ class ExportMgr: clients: list = [], sectype: Optional[List[str]] = None) -> Dict[str, Any]: - 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)