Skip to content

Commit c8f3182

Browse files
fix(TenantOverview): add correct tablet storage value (#1040)
1 parent 89b4782 commit c8f3182

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.tsx

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Loader} from '@gravity-ui/uikit';
22

33
import {EntityStatus} from '../../../../components/EntityStatus/EntityStatus';
4+
import {useGetSchemaQuery} from '../../../../store/reducers/schema/schema';
45
import {TENANT_METRICS_TABS_IDS} from '../../../../store/reducers/tenant/constants';
56
import {tenantApi} from '../../../../store/reducers/tenant/tenant';
67
import {calculateTenantMetrics} from '../../../../store/reducers/tenants/utils';
@@ -44,6 +45,35 @@ export function TenantOverview({
4445

4546
const tenantType = mapDatabaseTypeToDBName(Type);
4647

48+
// FIXME: remove after correct data is added to tenantInfo
49+
const {data: tenantSchemaData} = useGetSchemaQuery({path: tenantName});
50+
const {Tables, Topics} =
51+
tenantSchemaData?.PathDescription?.DomainDescription?.DiskSpaceUsage || {};
52+
53+
const usedTabletStorage = [
54+
Tables?.TotalSize,
55+
Topics?.AccountSize,
56+
Topics?.DataSize,
57+
Topics?.ReserveSize,
58+
Topics?.UsedReserveSize,
59+
].reduce((sum, current) => {
60+
if (current) {
61+
return sum + Number(current);
62+
}
63+
64+
return sum;
65+
}, 0);
66+
67+
const tenantData = {
68+
...tenant,
69+
Metrics: {
70+
...tenant?.Metrics,
71+
// Replace incorrect tenant metric with correct value
72+
Storage: String(usedTabletStorage),
73+
},
74+
};
75+
// === === ===
76+
4777
const {
4878
blobStorage,
4979
tabletStorage,
@@ -54,7 +84,7 @@ export function TenantOverview({
5484
memoryStats,
5585
blobStorageStats,
5686
tabletStorageStats,
57-
} = calculateTenantMetrics(tenant ?? undefined);
87+
} = calculateTenantMetrics(tenantData);
5888

5989
const storageMetrics = {
6090
blobStorageUsed: blobStorage,

src/types/api/schema/schema.ts

+23
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ interface TDomainState {
177177

178178
interface TDiskSpaceUsage {
179179
Tables?: TTables;
180+
Topics?: TTopics;
181+
TStoragePoolUsage?: TStoragePoolUsage[];
180182
}
181183

182184
interface TTables {
@@ -188,6 +190,27 @@ interface TTables {
188190
IndexSize?: string;
189191
}
190192

193+
interface TTopics {
194+
/** uint64 */
195+
ReserveSize?: string;
196+
/** uint64 */
197+
AccountSize?: string;
198+
/** uint64 */
199+
DataSize?: string;
200+
/** uint64 */
201+
UsedReserveSize?: string;
202+
}
203+
204+
interface TStoragePoolUsage {
205+
PoolKind?: string;
206+
/** uint64 */
207+
TotalSize?: string;
208+
/** uint64 */
209+
DataSize?: string;
210+
/** uint64 */
211+
IndexSize?: string;
212+
}
213+
191214
interface TStoragePool {
192215
Name?: string;
193216
Kind?: string;

0 commit comments

Comments
 (0)