From 14281d9991a276cf0c0dca53bfdab506f98af881 Mon Sep 17 00:00:00 2001 From: Sarthak0702 Date: Thu, 3 Feb 2022 23:29:17 +0530 Subject: [PATCH] mgr/dashboard:Directories Menu Can't Use on Ceph File System Dashboard Added exception handling to opendir() in cephfs.py for directories with no execute permission. Fixes: https://tracker.ceph.com/issues/51611 Signed-off-by: Sarthak0702 (cherry picked from commit ea1af5438d380eb2160de635ffc7b08a69baf04c) --- src/pybind/mgr/dashboard/controllers/cephfs.py | 3 +++ src/pybind/mgr/dashboard/services/exception.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/pybind/mgr/dashboard/controllers/cephfs.py b/src/pybind/mgr/dashboard/controllers/cephfs.py index d32cbe4bcfab6..5da79e35b48e1 100644 --- a/src/pybind/mgr/dashboard/controllers/cephfs.py +++ b/src/pybind/mgr/dashboard/controllers/cephfs.py @@ -10,6 +10,7 @@ from ..exceptions import DashboardException from ..security import Scope from ..services.ceph_service import CephService from ..services.cephfs import CephFS as CephFS_ +from ..services.exception import handle_cephfs_error from ..tools import ViewCache from . import APIDoc, APIRouter, EndpointDoc, RESTController, UIRouter, allow_empty_body @@ -363,6 +364,7 @@ class CephFS(RESTController): """ return cfs.get_directory(os.sep.encode()) + @handle_cephfs_error() @RESTController.Resource('GET') def ls_dir(self, fs_id, path=None, depth=1): """ @@ -517,6 +519,7 @@ class CephFsUi(CephFS): return data + @handle_cephfs_error() @RESTController.Resource('GET') def ls_dir(self, fs_id, path=None, depth=1): """ diff --git a/src/pybind/mgr/dashboard/services/exception.py b/src/pybind/mgr/dashboard/services/exception.py index feb084622bc0a..64fa6dc1c0f15 100644 --- a/src/pybind/mgr/dashboard/services/exception.py +++ b/src/pybind/mgr/dashboard/services/exception.py @@ -5,6 +5,7 @@ import json import logging from contextlib import contextmanager +import cephfs import cherrypy import rados import rbd @@ -55,6 +56,14 @@ def dashboard_exception_handler(handler, *args, **kwargs): raise error +@contextmanager +def handle_cephfs_error(): + try: + yield + except cephfs.OSError as e: + raise DashboardException(e, component='cephfs') from e + + @contextmanager def handle_rbd_error(): try: -- 2.39.5