From 02400577e01ce36a1e49d57c551548b446fe7ce1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Mon, 21 Jun 2021 21:31:49 +0800 Subject: [PATCH] mgr/dashboard: fix OSD out count MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Think we have 3 OSDs out but up (prepare for re-formatting to change min_alloc_size), and another OSD down but in (during reboot). The dashboard will display "1 down, 2 out", which is obviously incorrect. It should be "1 down, 3 out" Fixes: https://tracker.ceph.com/issues/51376 Signed-off-by: 胡玮文 (cherry picked from commit 921b48234777eba1a15c126f964cc47c0932879a) --- .../ceph/dashboard/osd-summary.pipe.spec.ts | 43 ++++++++++++++++--- .../app/ceph/dashboard/osd-summary.pipe.ts | 2 +- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/osd-summary.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/osd-summary.pipe.spec.ts index d5cdb598dcf1..f42a55dd4270 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/osd-summary.pipe.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/osd-summary.pipe.spec.ts @@ -46,7 +46,7 @@ describe('OsdSummaryPipe', () => { ]); }); - it('transforms having 3 osd with 2 up, 1 in, 1 down, 1 out', () => { + it('transforms having 3 osd with 2 up, 1 in, 1 down, 2 out', () => { const value = { osds: [ { up: 1, in: 1 }, @@ -72,18 +72,18 @@ describe('OsdSummaryPipe', () => { class: 'card-text-line-break' }, { - content: '1 down, 1 out', + content: '1 down, 2 out', class: 'card-text-error' } ]); }); - it('transforms having 3 osd with 2 up, 2 in, 1 down, 0 out', () => { + it('transforms having 3 osd with 2 up, 3 in, 1 down, 0 out', () => { const value = { osds: [ { up: 1, in: 1 }, { up: 1, in: 1 }, - { up: 0, in: 0 } + { up: 0, in: 1 } ] }; expect(pipe.transform(value)).toEqual([ @@ -96,7 +96,7 @@ describe('OsdSummaryPipe', () => { class: 'card-text-line-break' }, { - content: '2 up, 2 in', + content: '2 up, 3 in', class: '' }, { @@ -141,4 +141,37 @@ describe('OsdSummaryPipe', () => { } ]); }); + + it('transforms having 4 osd with 3 up, 2 in, 1 down, another 2 out', () => { + const value = { + osds: [ + { up: 1, in: 1 }, + { up: 1, in: 0 }, + { up: 1, in: 0 }, + { up: 0, in: 1 } + ] + }; + expect(pipe.transform(value)).toEqual([ + { + content: '4 total', + class: '' + }, + { + content: '', + class: 'card-text-line-break' + }, + { + content: '3 up, 2 in', + class: '' + }, + { + content: '', + class: 'card-text-line-break' + }, + { + content: '1 down, 2 out', + class: 'card-text-error' + } + ]); + }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/osd-summary.pipe.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/osd-summary.pipe.ts index 72bea4a0aeaa..26714ff2ae6b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/osd-summary.pipe.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/osd-summary.pipe.ts @@ -38,7 +38,7 @@ export class OsdSummaryPipe implements PipeTransform { }); const downCount = value.osds.length - upCount; - const outCount = upCount - inCount; + const outCount = value.osds.length - inCount; if (downCount > 0 || outCount > 0) { osdSummary.push({ content: '', -- 2.47.3