Skip to content

Commit e91e136

Browse files
fix(Storage): request only static nodes
1 parent bb5d1fa commit e91e136

File tree

6 files changed

+58
-19
lines changed

6 files changed

+58
-19
lines changed

src/services/api.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ interface Window {
1717
tenant: string;
1818
filter: string;
1919
nodeId: string;
20-
type: 'Groups' | 'Nodes';
2120
},
2221
axiosOptions?: AxiosOptions,
2322
) => Promise<import('../types/api/storage').TStorageInfo>;
23+
getNodes: (
24+
params: import('../types/store/nodes').INodesApiRequestParams,
25+
axiosOptions?: AxiosOptions,
26+
) => Promise<import('../types/api/nodes').TNodesInfo>;
27+
getCompute: (path: string) => Promise<import('../types/api/compute').TComputeInfo>;
2428
sendQuery: <
2529
Action extends import('../types/api/query').Actions,
2630
Schema extends import('../types/api/query').Schemas = undefined,

src/services/api.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import AxiosWrapper from '@gravity-ui/axios-wrapper';
22

33
import {backend as BACKEND} from '../store';
4-
import {StorageTypes} from '../store/reducers/storage';
54

65
const config = {withCredentials: !window.custom_backend};
76

@@ -14,9 +13,6 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
1413
getClusterInfo() {
1514
return this.get(this.getPath('/viewer/json/cluster'), {tablets: true});
1615
}
17-
getNodes(path) {
18-
return this.get(this.getPath('/viewer/json/compute?enums=true'), {path});
19-
}
2016
getNodeInfo(id) {
2117
return this.get(this.getPath('/viewer/json/sysinfo?enums=true'), {
2218
node_id: id,
@@ -35,11 +31,27 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
3531
storage: true,
3632
});
3733
}
38-
getStorageInfo({tenant, filter, nodeId, type}, {concurrentId} = {}) {
34+
getNodes({tenant, filter, storage, type = 'any', tablets = true}, {concurrentId} = {}) {
35+
return this.get(
36+
this.getPath('/viewer/json/nodes?enums=true'),
37+
{
38+
tenant,
39+
with: filter,
40+
storage,
41+
type,
42+
tablets,
43+
},
44+
{
45+
concurrentId,
46+
},
47+
);
48+
}
49+
getCompute(path) {
50+
return this.get(this.getPath('/viewer/json/compute?enums=true'), {path});
51+
}
52+
getStorageInfo({tenant, filter, nodeId}, {concurrentId} = {}) {
3953
return this.get(
40-
this.getPath(
41-
`/viewer/json/${type === StorageTypes.nodes ? 'nodes' : 'storage'}?enums=true`,
42-
),
54+
this.getPath(`/viewer/json/storage?enums=true`),
4355
{
4456
tenant,
4557
node_id: nodeId,

src/store/reducers/nodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const nodes: Reducer<INodesState, INodesAction> = (state = initialState, action)
7171

7272
export function getNodes(path: string) {
7373
return createApiRequest({
74-
request: window.api.getNodes(path),
74+
request: window.api.getCompute(path),
7575
actions: FETCH_NODES,
7676
});
7777
}

src/store/reducers/storage.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,15 @@ export function setInitialState() {
135135
}
136136

137137
export function getStorageInfo({tenant, filter, nodeId, type}, {concurrentId}) {
138+
if (type === StorageTypes.nodes) {
139+
return createApiRequest({
140+
request: window.api.getNodes({tenant, filter, type: 'static'}, {concurrentId}),
141+
actions: FETCH_STORAGE,
142+
});
143+
}
144+
138145
return createApiRequest({
139-
request: window.api.getStorageInfo({tenant, filter, nodeId, type}, {concurrentId}),
146+
request: window.api.getStorageInfo({tenant, filter, nodeId}, {concurrentId}),
140147
actions: FETCH_STORAGE,
141148
});
142149
}

src/store/reducers/tenant.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import _ from 'lodash';
55
const FETCH_TENANT = createRequestActionTypes('tenant', 'FETCH_TENANT');
66
const SET_TOP_LEVEL_TAB = 'tenant/SET_TOP_LEVEL_TAB';
77
const SET_DIAGNOSTICS_TAB = 'tenant/SET_DIAGNOSTICS_TAB';
8+
const CLEAR_TENANT = 'tenant/CLEAR_TENANT';
89

910
const tenantReducer = (state = {loading: false, wasLoaded: false, tenant: {}}, action) => {
1011
switch (action.type) {
@@ -37,7 +38,7 @@ const tenantReducer = (state = {loading: false, wasLoaded: false, tenant: {}}, a
3738
};
3839
}
3940

40-
case 'CLEAR_TENANT': {
41+
case CLEAR_TENANT: {
4142
return {
4243
...state,
4344
tenant: {},
@@ -65,12 +66,12 @@ const tenantReducer = (state = {loading: false, wasLoaded: false, tenant: {}}, a
6566
};
6667

6768
export const clearTenant = () => {
68-
return {type: 'CLEAR_TENANT'};
69+
return {type: CLEAR_TENANT};
6970
};
7071

7172
export const getTenantInfo = ({path}) => {
7273
return createApiRequest({
73-
request: Promise.all([window.api.getTenantInfo({path}), window.api.getNodes(path)]),
74+
request: Promise.all([window.api.getTenantInfo({path}), window.api.getCompute(path)]),
7475
actions: FETCH_TENANT,
7576
dataHandler: ([tenantData, nodesData]) => {
7677
const tenant = tenantData.TenantInfo[0];
@@ -83,7 +84,7 @@ export const getTenantInfo = ({path}) => {
8384
};
8485
}
8586

86-
return;
87+
return undefined;
8788
}).filter(Boolean);
8889

8990
return {tenant, tenantNodes};

src/types/store/nodes.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import type {IResponseError} from '../api/error';
2+
import type {TComputeInfo} from '../api/compute';
3+
14
import {NodesUptimeFilterValues} from '../../utils/nodes';
25
import {
36
FETCH_NODES,
@@ -6,18 +9,30 @@ import {
69
setNodesUptimeFilter,
710
} from '../../store/reducers/nodes';
811
import {ApiRequestAction} from '../../store/utils';
9-
import {IResponseError} from '../api/error';
10-
import {TNodesInfo} from '../api/nodes';
1112

1213
export interface INodesState {
1314
loading: boolean;
1415
wasLoaded: boolean;
1516
nodesUptimeFilter: NodesUptimeFilterValues;
16-
data?: TNodesInfo;
17+
data?: TComputeInfo;
1718
error?: IResponseError;
1819
}
1920

20-
type INodesApiRequestAction = ApiRequestAction<typeof FETCH_NODES, TNodesInfo, IResponseError>;
21+
type INodesApiRequestNodeType = 'static' | 'dynamic' | 'any';
22+
23+
// Space - out of space nodes
24+
// Missing - nodes with missing disks
25+
type INodesApiRequestProblemType = 'missing' | 'space';
26+
27+
export interface INodesApiRequestParams {
28+
tenant?: string;
29+
type?: INodesApiRequestNodeType;
30+
filter?: INodesApiRequestProblemType;
31+
storage?: boolean;
32+
tablets?: boolean;
33+
}
34+
35+
type INodesApiRequestAction = ApiRequestAction<typeof FETCH_NODES, TComputeInfo, IResponseError>;
2136

2237
export type INodesAction =
2338
| INodesApiRequestAction

0 commit comments

Comments
 (0)