]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix consumption chart units 67667/head
authorAashish Sharma <aashish@li-e9bf2ecc-2ad7-11b2-a85c-baf05c5182ab.ibm.com>
Thu, 5 Mar 2026 04:30:02 +0000 (10:00 +0530)
committerAashish Sharma <aashish@li-e9bf2ecc-2ad7-11b2-a85c-baf05c5182ab.ibm.com>
Mon, 9 Mar 2026 09:55:17 +0000 (15:25 +0530)
Fixes: https://tracker.ceph.com/issues/75278
Fixes: https://tracker.ceph.com/issues/75319
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/storage-card/overview-storage-card.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/api/storage-overview.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/storage-overview.service.ts

index 382e5b9618da3e2653dd3b49b45fdeed75ec13e0..0bb28a579a1efe66b93f7863aa47a75e19c3144c 100644 (file)
@@ -74,7 +74,7 @@
               description="Based on recent average consumption. Actual time until full may vary based on changes in consumption patterns."
               i18n-description
               i18n>
-              Estimated days until full
+              Estimated time until full
             </cds-tooltip-definition>
           </div>
         </div>
index 19d6589076e131b1b7bb67e0c49f5fb5f9d8afca..2f28b9fc9bccce8d372c77fe3240aab3ad03165b 100644 (file)
@@ -26,7 +26,7 @@ describe('OverviewStorageService', () => {
       service.getTrendData(1000, 2000, 60);
       expect(promSpy).toHaveBeenCalledWith(
         { start: 1000, end: 2000, step: 60 },
-        { TOTAL_RAW_USED: 'sum(ceph_pool_bytes_used)' },
+        { TOTAL_RAW_USED: 'sum(ceph_osd_stat_bytes_used)' },
         true
       );
     });
@@ -71,13 +71,13 @@ describe('OverviewStorageService', () => {
   });
 
   describe('getTimeUntilFull', () => {
-    it('should return  when days is Infinity', (done) => {
+    it('should return N/A when days is Infinity', (done) => {
       jest
         .spyOn(service['prom'], 'getPrometheusQueryData')
         .mockReturnValue(new (require('rxjs').of)({ result: [] }));
 
       service.getTimeUntilFull().subscribe((result) => {
-        expect(result).toBe('');
+        expect(result).toBe('N/A');
         done();
       });
     });
@@ -115,13 +115,13 @@ describe('OverviewStorageService', () => {
       });
     });
 
-    it('should return  when days <= 0', (done) => {
+    it('should return N/A when days <= 0', (done) => {
       jest
         .spyOn(service['prom'], 'getPrometheusQueryData')
         .mockReturnValue(new (require('rxjs').of)({ result: [{ value: [null, '-5'] }] }));
 
       service.getTimeUntilFull().subscribe((result) => {
-        expect(result).toBe('');
+        expect(result).toBe('N/A');
         done();
       });
     });
index f68337b2b631dcf80e3e95cb2c6eb9a575cea4b1..f10fa9eabfaa7116d6ec516058b2a32f2ec53526 100644 (file)
@@ -8,9 +8,9 @@ import { forkJoin, Observable } from 'rxjs';
 export class OverviewStorageService {
   private readonly prom = inject(PrometheusService);
   private readonly formatter = inject(FormatterService);
-  private readonly AVG_CONSUMPTION_QUERY = 'sum(rate(ceph_pool_bytes_used[7d])) * 86400';
-  private readonly TIME_UNTIL_FULL_QUERY = `(sum(ceph_pool_max_avail)) / (sum(rate(ceph_pool_bytes_used[7d])) * 86400)`;
-  private readonly TOTAL_RAW_USED_QUERY = 'sum(ceph_pool_bytes_used)';
+  private readonly AVG_CONSUMPTION_QUERY = 'sum(rate(ceph_osd_stat_bytes_used[7d])) * 86400';
+  private readonly TIME_UNTIL_FULL_QUERY = `(sum(ceph_osd_stat_bytes)) / (sum(rate(ceph_osd_stat_bytes_used[7d])) * 86400)`;
+  private readonly TOTAL_RAW_USED_QUERY = 'sum(ceph_osd_stat_bytes_used)';
   private readonly OBJECT_POOLS_COUNT_QUERY = 'count(ceph_pool_metadata{application="Object"})';
 
   getTrendData(start: number, end: number, stepSec: number) {
@@ -43,11 +43,12 @@ export class OverviewStorageService {
     return this.prom.getPrometheusQueryData({ params: this.TIME_UNTIL_FULL_QUERY }).pipe(
       map((res) => {
         const days = Number(res?.result?.[0]?.value?.[1] ?? Infinity);
-        if (!isFinite(days) || days <= 0) return '';
+        if (!isFinite(days) || days <= 0) return 'N/A';
 
         if (days < 1) return `${(days * 24).toFixed(1)} hours`;
         if (days < 30) return `${days.toFixed(1)} days`;
-        return `${(days / 30).toFixed(1)} months`;
+        if (days < 365) return `${(days / 30).toFixed(1)} months`;
+        return `${(days / 365).toFixed(1)} years`;
       })
     );
   }