Skip to content

Commit 7315a9c

Browse files
committed
feat(Storage): vividly show degraded disks count
1 parent d318d7a commit 7315a9c

File tree

5 files changed

+117
-12
lines changed

5 files changed

+117
-12
lines changed

src/containers/Storage/StorageGroups/StorageGroups.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _ from 'lodash';
22
import cn from 'bem-cn-lite';
33
import DataTable, {Column, Settings, SortOrder} from '@yandex-cloud/react-data-table';
4-
import {Popover, PopoverBehavior} from '@yandex-cloud/uikit';
4+
import {Label, Popover, PopoverBehavior} from '@yandex-cloud/uikit';
55

66
import {Stack} from '../../../components/Stack/Stack';
77
//@ts-ignore
@@ -16,7 +16,7 @@ import {bytesToGB, bytesToSpeed} from '../../../utils/utils';
1616
import {stringifyVdiskId} from '../../../utils';
1717

1818
import Vdisk from '../Vdisk/Vdisk';
19-
import {isFullDonorData} from '../utils';
19+
import {isFullDonorData, getDegradedSeverity} from '../utils';
2020

2121
import './StorageGroups.scss';
2222

@@ -53,7 +53,7 @@ const tableColumnsNames: Record<TableColumnsIdsValues, string> = {
5353
Read: 'Read',
5454
Write: 'Write',
5555
VDisks: 'VDisks',
56-
Missing: 'Missing',
56+
Missing: 'Degraded',
5757
};
5858

5959
const b = cn('global-storage-groups');
@@ -62,8 +62,8 @@ function setSortOrder(visibleEntities: keyof typeof VisibleEntities): SortOrder
6262
switch (visibleEntities) {
6363
case VisibleEntities.All: {
6464
return {
65-
columnId: TableColumnsIds.GroupID,
66-
order: DataTable.ASCENDING,
65+
columnId: TableColumnsIds.Missing,
66+
order: DataTable.DESCENDING,
6767
};
6868
}
6969
case VisibleEntities.Missing: {
@@ -110,6 +110,16 @@ function StorageGroups({data, tableSettings, visibleEntities, nodes}: StorageGro
110110
},
111111
align: DataTable.LEFT,
112112
},
113+
{
114+
name: TableColumnsIds.Missing,
115+
header: tableColumnsNames[TableColumnsIds.Missing],
116+
width: 100,
117+
render: ({value, row}) => value ? (
118+
<Label theme={getDegradedSeverity(row)}>Degraded: {value}</Label>
119+
) : '-',
120+
align: DataTable.LEFT,
121+
defaultOrder: DataTable.DESCENDING,
122+
},
113123
{
114124
name: TableColumnsIds.GroupID,
115125
header: tableColumnsNames[TableColumnsIds.GroupID],
@@ -186,13 +196,6 @@ function StorageGroups({data, tableSettings, visibleEntities, nodes}: StorageGro
186196
},
187197
align: DataTable.RIGHT,
188198
},
189-
{
190-
name: TableColumnsIds.Missing,
191-
header: tableColumnsNames[TableColumnsIds.Missing],
192-
width: 100,
193-
align: DataTable.CENTER,
194-
defaultOrder: DataTable.DESCENDING,
195-
},
196199
{
197200
name: TableColumnsIds.VDisks,
198201
className: b('vdisks-column'),
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
11
import type {TVDiskStateInfo, TVSlotId} from '../../../types/api/storage';
2+
import type {IStoragePoolGroup} from '../../../types/store/storage';
23

34
export * from './constants';
45

56
export const isFullDonorData = (donor: TVDiskStateInfo | TVSlotId): donor is TVDiskStateInfo =>
67
'VDiskId' in donor;
8+
9+
const generateEvaluator = (warn: number, crit: number) =>
10+
(value: number) => {
11+
if (0 <= value && value < warn) {
12+
return 'success';
13+
}
14+
15+
if (warn <= value && value < crit) {
16+
return 'warning';
17+
}
18+
19+
if (crit <= value) {
20+
return 'danger';
21+
}
22+
23+
return undefined;
24+
};
25+
26+
const defaultDegradationEvaluator = generateEvaluator(1, 2);
27+
28+
const degradationEvaluators = {
29+
'block-4-2': generateEvaluator(1, 2),
30+
'mirror-3-dc': generateEvaluator(1, 3),
31+
};
32+
33+
const canEvaluateErasureSpecies = (value?: string): value is keyof typeof degradationEvaluators =>
34+
value !== undefined && value in degradationEvaluators;
35+
36+
export const getDegradedSeverity = (group: IStoragePoolGroup) => {
37+
const evaluate = canEvaluateErasureSpecies(group.ErasureSpecies) ?
38+
degradationEvaluators[group.ErasureSpecies] :
39+
defaultDegradationEvaluator;
40+
41+
return evaluate(group.Missing);
42+
};

src/services/api.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ interface Window {
44
params: {path: string},
55
axiosOptions?: {concurrentId?: string},
66
) => Promise<import('../types/api/schema').TEvDescribeSchemeResult>;
7+
getStorageInfo: (
8+
params: {
9+
tenant: string,
10+
filter: string,
11+
nodeId: string,
12+
type: 'Groups' | 'Nodes',
13+
},
14+
axiosOptions?: {concurrentId?: string},
15+
) => Promise<import('../types/api/storage').TStorageInfo>;
716
[method: string]: Function;
817
};
918
}

src/types/api/storage.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,49 @@ export interface TVDiskStateInfo {
170170
*/
171171
WriteThroughput?: string;
172172
}
173+
174+
export interface TBSGroupStateInfo {
175+
/** uint32 */
176+
GroupID?: string;
177+
ErasureSpecies?: string;
178+
VDisks?: TVDiskStateInfo[];
179+
/** uint64 */
180+
ChangeTime?: string;
181+
/** uint32 */
182+
NodeId?: string; // filled during merge
183+
/** uint32 */
184+
GroupGeneration?: string;
185+
Overall?: EFlag;
186+
Latency?: EFlag;
187+
/** uint32 */
188+
Count?: string; // filled during group count
189+
StoragePoolName?: string; // from BS_CONTROLLER
190+
}
191+
192+
export interface TStoragePoolInfo {
193+
Overall?: EFlag;
194+
Name?: string;
195+
Kind?: string;
196+
Groups?: TBSGroupStateInfo[];
197+
/** uint64 */
198+
AcquiredUnits?: string;
199+
AcquiredIOPS?: number;
200+
/** uint64 */
201+
AcquiredThroughput?: string;
202+
/** uint64 */
203+
AcquiredSize?: string;
204+
MaximumIOPS?: number;
205+
/** uint64 */
206+
MaximumThroughput?: string;
207+
/** uint64 */
208+
MaximumSize?: string;
209+
}
210+
211+
export interface TStorageInfo {
212+
Overall?: EFlag;
213+
StoragePools?: TStoragePoolInfo[];
214+
/** uint64 */
215+
TotalGroups?: string;
216+
/** uint64 */
217+
FoundGroups?: string;
218+
}

src/types/store/storage.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type {TBSGroupStateInfo} from '../api/storage';
2+
3+
export interface IStoragePoolGroup extends TBSGroupStateInfo {
4+
Read: number;
5+
Write: number;
6+
PoolName?: string;
7+
Used: number;
8+
Limit: number;
9+
Missing: number;
10+
UsedSpaceFlag: number;
11+
}

0 commit comments

Comments
 (0)