]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Fix calculation of PG Status percentage
authorTiago Melo <tmelo@suse.com>
Wed, 11 Sep 2019 14:53:23 +0000 (14:53 +0000)
committerTiago Melo <tmelo@suse.com>
Wed, 11 Sep 2019 14:59:03 +0000 (14:59 +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>
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 c41bc4f9d780858ce1cb61dfeeeca02ea63a502f..3906e559cf87886b362cf6018e74072a74725e42 100644 (file)
@@ -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)}%)`
     ];
   }