From: 胡玮文 Date: Mon, 21 Jun 2021 13:31:49 +0000 (+0800) Subject: mgr/dashboard: fix OSD out count X-Git-Tag: v16.2.5~2^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=02400577e01ce36a1e49d57c551548b446fe7ce1;p=ceph.git mgr/dashboard: fix OSD out count 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) --- 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: '',