From: Tiago Melo Date: Wed, 11 Sep 2019 14:53:23 +0000 (+0000) Subject: mgr/dashboard: Fix calculation of PG Status percentage X-Git-Tag: v15.1.0~1574^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1be47eb2aea68acffff7c25581e764a12ccdd4e7;p=ceph.git mgr/dashboard: Fix calculation of PG Status percentage We were reading a wrong value for the total of PGs. Fixes: https://tracker.ceph.com/issues/41536 Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts index 8c89000ca37d..de7892a07a68 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts @@ -272,7 +272,7 @@ describe('HealthComponent', () => { it('gets no data', () => { const chart = { dataset: [{}], options: {} }; component.preparePgStatus(chart, { - pg_info: { pgs_per_osd: 0 } + pg_info: {} }); expect(chart).toEqual(expectedChart([undefined, undefined, undefined, undefined])); }); @@ -281,7 +281,6 @@ describe('HealthComponent', () => { const chart = { dataset: [{}], options: {} }; component.preparePgStatus(chart, { pg_info: { - pgs_per_osd: 10, statuses: { 'clean+active+scrubbing+nonMappedState': 4, 'clean+active+scrubbing': 2, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.ts index c41bc4f9d780..3906e559cf87 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.ts @@ -148,6 +148,7 @@ export class HealthComponent implements OnInit, OnDestroy { preparePgStatus(chart, data) { const categoryPgAmount = {}; + let totalPgs = 0; _.forEach(data.pg_info.statuses, (pgAmount, pgStatesText) => { const categoryType = this.pgCategoryService.getTypeByStates(pgStatesText); @@ -156,6 +157,7 @@ export class HealthComponent implements OnInit, OnDestroy { categoryPgAmount[categoryType] = 0; } categoryPgAmount[categoryType] += pgAmount; + totalPgs += pgAmount; }); chart.dataset[0].data = this.pgCategoryService @@ -163,22 +165,10 @@ export class HealthComponent implements OnInit, OnDestroy { .map((categoryType) => categoryPgAmount[categoryType]); chart.labels = [ - `${this.i18n('Clean')} (${this.calcPercentage( - categoryPgAmount['clean'], - data.pg_info.pgs_per_osd - )}%)`, - `${this.i18n('Working')} (${this.calcPercentage( - categoryPgAmount['working'], - data.pg_info.pgs_per_osd - )}%)`, - `${this.i18n('Warning')} (${this.calcPercentage( - categoryPgAmount['warning'], - data.pg_info.pgs_per_osd - )}%)`, - `${this.i18n('Unknown')} (${this.calcPercentage( - categoryPgAmount['unknown'], - data.pg_info.pgs_per_osd - )}%)` + `${this.i18n('Clean')} (${this.calcPercentage(categoryPgAmount['clean'], totalPgs)}%)`, + `${this.i18n('Working')} (${this.calcPercentage(categoryPgAmount['working'], totalPgs)}%)`, + `${this.i18n('Warning')} (${this.calcPercentage(categoryPgAmount['warning'], totalPgs)}%)`, + `${this.i18n('Unknown')} (${this.calcPercentage(categoryPgAmount['unknown'], totalPgs)}%)` ]; }