]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Fix calculation of PG Status percentage 30394/head
authorTiago Melo <tmelo@suse.com>
Wed, 11 Sep 2019 14:53:23 +0000 (14:53 +0000)
committerTiago Melo <tmelo@suse.com>
Mon, 16 Sep 2019 09:04:23 +0000 (09:04 +0000)
We were reading a wrong value for the total of PGs.

Fixes: https://tracker.ceph.com/issues/41536
Signed-off-by: Tiago Melo <tmelo@suse.com>
(cherry picked from commit 1be47eb2aea68acffff7c25581e764a12ccdd4e7)

src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.ts

index 8c89000ca37d7237788f628aaf15ac4b543f60c8..de7892a07a682f6715c1278972edd56ae349800f 100644 (file)
@@ -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,
index 6cca3b5cac495862d4e0960c1deca8eda5e91fd8..3bc78c70074e19251a54b5767e54cc88c88c25af 100644 (file)
@@ -146,6 +146,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);
@@ -154,6 +155,7 @@ export class HealthComponent implements OnInit, OnDestroy {
         categoryPgAmount[categoryType] = 0;
       }
       categoryPgAmount[categoryType] += pgAmount;
+      totalPgs += pgAmount;
     });
 
     chart.dataset[0].data = this.pgCategoryService
@@ -161,22 +163,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)}%)`
     ];
   }