From e1e4d3850f649d6393957d13f02b0131fa3226d6 Mon Sep 17 00:00:00 2001 From: Ernesto Puerta Date: Wed, 29 Jun 2022 20:09:21 +0200 Subject: [PATCH] mgr/dashboard: don't log tracebacks on 404s Currently we're logging tracebacks on expected request errors as 404, 401, etc. This may cause confusion to users, which might think that something really wrong was happening there. This should be extended to many DashboardExceptions that simply return expected HTTP error codes (403, 415, 3xx, etc). Fixes: https://tracker.ceph.com/issues/55720 Signed-off-by: Ernesto Puerta (cherry picked from commit 3928fe91a4b8c313a52e38cab9ba31e54ff1ae51) --- src/pybind/mgr/dashboard/services/exception.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/dashboard/services/exception.py b/src/pybind/mgr/dashboard/services/exception.py index 80c4b372afa35..09851aa467e0f 100644 --- a/src/pybind/mgr/dashboard/services/exception.py +++ b/src/pybind/mgr/dashboard/services/exception.py @@ -45,15 +45,14 @@ def dashboard_exception_handler(handler, *args, **kwargs): try: with handle_rados_error(component=None): # make the None controller the fallback. return handler(*args, **kwargs) - # Don't catch cherrypy.* Exceptions. + # pylint: disable=try-except-raise + except (cherrypy.HTTPRedirect, cherrypy.NotFound, cherrypy.HTTPError): + raise except (ViewCacheNoDataException, DashboardException) as error: logger.exception('Dashboard Exception') cherrypy.response.headers['Content-Type'] = 'application/json' cherrypy.response.status = getattr(error, 'status', 400) return json.dumps(serialize_dashboard_exception(error)).encode('utf-8') - except cherrypy.HTTPRedirect: - # No internal errors - raise except Exception as error: logger.exception('Internal Server Error') raise error -- 2.39.5