From: Aashish Sharma Date: Thu, 5 Mar 2026 04:30:02 +0000 (+0530) Subject: mgr/dashboard: fix consumption chart units X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ee24cf564612ea645ae2a2dd141e0784e44ab09d;p=ceph.git mgr/dashboard: fix consumption chart units Fixes: https://tracker.ceph.com/issues/75278 Fixes: https://tracker.ceph.com/issues/75319 Signed-off-by: Aashish Sharma --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/storage-card/overview-storage-card.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/storage-card/overview-storage-card.component.html index 382e5b9618d..0bb28a579a1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/storage-card/overview-storage-card.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/storage-card/overview-storage-card.component.html @@ -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 diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/storage-overview.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/storage-overview.service.spec.ts index 19d6589076e..2f28b9fc9bc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/storage-overview.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/storage-overview.service.spec.ts @@ -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(); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/storage-overview.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/storage-overview.service.ts index f68337b2b63..f10fa9eabfa 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/storage-overview.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/storage-overview.service.ts @@ -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`; }) ); }