From 09f2bb4c9a96318e1720c54759f09747f487a2af Mon Sep 17 00:00:00 2001 From: Patrick Nawracay Date: Sat, 17 Nov 2018 22:03:22 +0100 Subject: [PATCH] mgr/dashboard: Fix failing QA test: test_safe_to_destroy The behavior of `safe-to-destroy` has changed in 432f19435523d455ecd4f386e58ee1f033cf97e2 (PR#24799) and the backend needs to be adapted accordingly. Fixes: http://tracker.ceph.com/issues/37290 Signed-off-by: Patrick Nawracay --- qa/tasks/mgr/dashboard/test_osd.py | 12 +++++++++--- src/pybind/mgr/dashboard/controllers/osd.py | 8 +++++--- .../cluster/osd/osd-list/osd-list.component.html | 6 +++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/qa/tasks/mgr/dashboard/test_osd.py b/qa/tasks/mgr/dashboard/test_osd.py index e85a718691c..46a773060a3 100644 --- a/qa/tasks/mgr/dashboard/test_osd.py +++ b/qa/tasks/mgr/dashboard/test_osd.py @@ -102,12 +102,18 @@ class OsdTest(DashboardTestCase): unused_osd_id = max(map(lambda e: e['osd'], osd_dump['osds'])) + 10 self._get('/api/osd/{}/safe_to_destroy'.format(unused_osd_id)) self.assertStatus(200) - self.assertJsonBody({'safe-to-destroy': True}) + self.assertJsonBody({ + 'is_safe_to_destroy': True, + 'active': [], + 'missing_stats': [], + 'safe_to_destroy': [unused_osd_id], + 'stored_pgs': [], + }) def get_destroy_status(): self._get('/api/osd/0/safe_to_destroy') - if 'safe-to-destroy' in self.jsonBody(): - return self.jsonBody()['safe-to-destroy'] + if 'is_safe_to_destroy' in self.jsonBody(): + return self.jsonBody()['is_safe_to_destroy'] return None self.wait_until_equal(get_destroy_status, False, 10) self.assertStatus(200) diff --git a/src/pybind/mgr/dashboard/controllers/osd.py b/src/pybind/mgr/dashboard/controllers/osd.py index a5f5e2f613b..08c141c8842 100644 --- a/src/pybind/mgr/dashboard/controllers/osd.py +++ b/src/pybind/mgr/dashboard/controllers/osd.py @@ -168,13 +168,15 @@ class Osd(RESTController): svc_id = [svc_id] svc_id = list(map(str, svc_id)) try: - CephService.send_command( + result = CephService.send_command( 'mon', 'osd safe-to-destroy', ids=svc_id, target=('mgr', '')) - return {'safe-to-destroy': True} + result['is_safe_to_destroy'] = set(result['safe_to_destroy']) == set(map(int, svc_id)) + return result + except SendCommandError as e: return { 'message': str(e), - 'safe-to-destroy': False, + 'is_safe_to_destroy': False, } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html index dffa66292da..96fb807a2e8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html @@ -68,10 +68,10 @@ -
- - {{ safeToDestroyResult.message }} + + The OSD is not safe to destroy!
OSD {{ selection.first().id }} will be -- 2.39.5