From 19709c6c63ad2cbd80e87e1ec1000631ea09d65d Mon Sep 17 00:00:00 2001 From: Aashish Sharma Date: Wed, 16 Sep 2020 19:13:04 +0530 Subject: [PATCH] mgr/dashboard/api: move/create OSD histogram in separate endpoint Added a separate endpoint for osd/histogram - api/osd/{svc_id}/histogram Fixes:https://tracker.ceph.com/issues/46898 Signed-off-by: Aashish Sharma (cherry picked from commit 1c812e0d61ec8320cb5d3864199af9c31b2aa238) --- qa/tasks/mgr/dashboard/test_osd.py | 6 ++++++ src/pybind/mgr/dashboard/controllers/osd.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/qa/tasks/mgr/dashboard/test_osd.py b/qa/tasks/mgr/dashboard/test_osd.py index 0bd3f93f324..3f6c03e851e 100644 --- a/qa/tasks/mgr/dashboard/test_osd.py +++ b/qa/tasks/mgr/dashboard/test_osd.py @@ -54,6 +54,12 @@ class OsdTest(DashboardTestCase): self.assert_in_and_not_none(data['histogram']['osd'], ['op_w_latency_in_bytes_histogram', 'op_r_latency_out_bytes_histogram']) + def test_histogram(self): + data = self._get('/api/osd/0/histogram') + self.assertStatus(200) + self.assert_in_and_not_none(data['osd'], ['op_w_latency_in_bytes_histogram', + 'op_r_latency_out_bytes_histogram']) + def test_scrub(self): self._post('/api/osd/0/scrub?deep=False') self.assertStatus(200) diff --git a/src/pybind/mgr/dashboard/controllers/osd.py b/src/pybind/mgr/dashboard/controllers/osd.py index e29a056a167..fa7a6fc7019 100644 --- a/src/pybind/mgr/dashboard/controllers/osd.py +++ b/src/pybind/mgr/dashboard/controllers/osd.py @@ -117,6 +117,22 @@ class Osd(RESTController): 'histogram': histogram, } + @RESTController.Resource('GET') + @handle_send_command_error('osd') + def histogram(self, svc_id): + # type: (int) -> Dict[str, Any] + """ + :return: Returns the histogram data. + """ + try: + histogram = CephService.send_command( + 'osd', srv_spec=svc_id, prefix='perf histogram dump') + except SendCommandError as e: # pragma: no cover - the handling is too obvious + raise DashboardException( + component='osd', http_status_code=400, msg=str(e)) + + return histogram + def set(self, svc_id, device_class): # pragma: no cover old_device_class = CephService.send_command('mon', 'osd crush get-device-class', ids=[svc_id]) -- 2.47.3