Skip to content

Commit de315ae

Browse files
fix: remove break nodes setting, remove compute (#1306)
1 parent d115989 commit de315ae

File tree

12 files changed

+17
-200
lines changed

12 files changed

+17
-200
lines changed

src/components/TabletsStatistic/TabletsStatistic.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import {Link} from 'react-router-dom';
22

33
import {TABLETS} from '../../containers/Node/NodePages';
44
import routes, {createHref} from '../../routes';
5-
import type {TTabletStateInfo as TComputeTabletStateInfo} from '../../types/api/compute';
6-
import type {TTabletStateInfo as TFullTabletStateInfo} from '../../types/api/tablet';
5+
import type {TTabletStateInfo} from '../../types/api/tablet';
76
import {cn} from '../../utils/cn';
87
import {getTabletLabel} from '../../utils/constants';
98
import {mapTabletStateToColorState} from '../../utils/tablet';
@@ -12,9 +11,7 @@ import './TabletsStatistic.scss';
1211

1312
const b = cn('tablets-statistic');
1413

15-
type Tablets = TFullTabletStateInfo[] | TComputeTabletStateInfo[];
16-
17-
const prepareTablets = (tablets: Tablets) => {
14+
const prepareTablets = (tablets: TTabletStateInfo[]) => {
1815
const res = tablets.map((tablet) => {
1916
return {
2017
label: getTabletLabel(tablet.Type),
@@ -28,7 +25,7 @@ const prepareTablets = (tablets: Tablets) => {
2825
};
2926

3027
interface TabletsStatisticProps {
31-
tablets: Tablets;
28+
tablets: TTabletStateInfo[];
3229
path: string | undefined;
3330
nodeId: string | number;
3431
backend?: string;

src/containers/Nodes/Nodes.tsx

+6-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22

33
import {ASCENDING} from '@gravity-ui/react-data-table/build/esm/lib/constants';
4-
import {skipToken} from '@reduxjs/toolkit/query';
54
import {StringParam, useQueryParams} from 'use-query-params';
65

76
import {EntitiesCount} from '../../components/EntitiesCount';
@@ -25,10 +24,9 @@ import {
2524
import type {ProblemFilterValue} from '../../store/reducers/settings/types';
2625
import type {AdditionalNodesProps} from '../../types/additionalProps';
2726
import {cn} from '../../utils/cn';
28-
import {DEFAULT_TABLE_SETTINGS, USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY} from '../../utils/constants';
27+
import {DEFAULT_TABLE_SETTINGS} from '../../utils/constants';
2928
import {
3029
useAutoRefreshInterval,
31-
useSetting,
3230
useTableSort,
3331
useTypedDispatch,
3432
useTypedSelector,
@@ -66,21 +64,11 @@ export const Nodes = ({path, database, additionalNodesProps = {}}: NodesProps) =
6664
const problemFilter = useTypedSelector(selectProblemFilter);
6765
const [autoRefreshInterval] = useAutoRefreshInterval();
6866

69-
const [useNodesEndpoint] = useSetting(USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY);
70-
71-
// If there is no path, it's cluster Nodes tab
72-
const useGetComputeNodes = path && !useNodesEndpoint;
73-
const nodesQuery = nodesApi.useGetNodesQuery(
74-
useGetComputeNodes ? skipToken : {path, database},
75-
{
76-
pollingInterval: autoRefreshInterval,
77-
},
78-
);
79-
const computeQuery = nodesApi.useGetComputeNodesQuery(useGetComputeNodes ? {path} : skipToken, {
80-
pollingInterval: autoRefreshInterval,
81-
});
82-
83-
const {currentData: data, isLoading, error} = useGetComputeNodes ? computeQuery : nodesQuery;
67+
const {
68+
currentData: data,
69+
isLoading,
70+
error,
71+
} = nodesApi.useGetNodesQuery({path, database}, {pollingInterval: autoRefreshInterval});
8472

8573
const [sortValue, setSortValue] = React.useState<NodesSortParams>({
8674
sortValue: 'NodeId',

src/containers/UserSettings/i18n/en.json

-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030

3131
"settings.invertedDisks.title": "Inverted disks space indicators",
3232

33-
"settings.useNodesEndpoint.title": "Break the Nodes tab in Diagnostics",
34-
"settings.useNodesEndpoint.description": "Use /viewer/json/nodes endpoint for Nodes tab in diagnostics. It could return incorrect data on versions before 24-1",
35-
3633
"settings.useAdvancedStorage.title": "Use advanced storage",
3734
"settings.useAdvancedStorage.description": "Display additional data in Storage table",
3835

src/containers/UserSettings/settings.tsx

+1-12
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
THEME_KEY,
1414
USE_ADVANCED_STORAGE_KEY,
1515
USE_CLUSTER_BALANCER_AS_BACKEND_KEY,
16-
USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
1716
USE_PAGINATED_TABLES_KEY,
1817
} from '../../utils/constants';
1918
import {Lang, defaultLang} from '../../utils/i18n';
@@ -91,11 +90,6 @@ export const invertedDisksSetting: SettingProps = {
9190
settingKey: INVERTED_DISKS_KEY,
9291
title: i18n('settings.invertedDisks.title'),
9392
};
94-
export const useNodesEndpointSetting: SettingProps = {
95-
settingKey: USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
96-
title: i18n('settings.useNodesEndpoint.title'),
97-
description: i18n('settings.useNodesEndpoint.description'),
98-
};
9993
export const useAdvancedStorageSetting: SettingProps = {
10094
settingKey: USE_ADVANCED_STORAGE_KEY,
10195
title: i18n('settings.useAdvancedStorage.title'),
@@ -155,12 +149,7 @@ export const appearanceSection: SettingsSection = {
155149
export const experimentsSection: SettingsSection = {
156150
id: 'experimentsSection',
157151
title: i18n('section.experiments'),
158-
settings: [
159-
useNodesEndpointSetting,
160-
useAdvancedStorageSetting,
161-
usePaginatedTables,
162-
queryUseMultiSchemaSetting,
163-
],
152+
settings: [useAdvancedStorageSetting, usePaginatedTables, queryUseMultiSchemaSetting],
164153
};
165154
export const devSettingsSection: SettingsSection = {
166155
id: 'devSettingsSection',

src/services/api.ts

+1-15
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import type {AxiosRequestConfig} from 'axios';
44
import axiosRetry from 'axios-retry';
55

66
import {backend as BACKEND, metaBackend as META_BACKEND} from '../store';
7-
import type {ComputeApiRequestParams, NodesApiRequestParams} from '../store/reducers/nodes/types';
7+
import type {NodesApiRequestParams} from '../store/reducers/nodes/types';
88
import type {TMetaInfo} from '../types/api/acl';
99
import type {TQueryAutocomplete} from '../types/api/autocomplete';
1010
import type {CapabilitiesResponse} from '../types/api/capabilities';
1111
import type {TClusterInfo} from '../types/api/cluster';
12-
import type {TComputeInfo} from '../types/api/compute';
1312
import type {DescribeConsumerResult} from '../types/api/consumer';
1413
import type {FeatureFlagConfigs} from '../types/api/featureFlags';
1514
import type {HealthCheckAPIResponse} from '../types/api/healthcheck';
@@ -224,19 +223,6 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
224223
{concurrentId, requestConfig: {signal}},
225224
);
226225
}
227-
/** @deprecated use getNodes instead */
228-
getCompute(
229-
{sortOrder, sortValue, ...params}: ComputeApiRequestParams,
230-
{concurrentId, signal}: AxiosOptions = {},
231-
) {
232-
const sort = prepareSortValue(sortValue, sortOrder);
233-
234-
return this.get<TComputeInfo>(
235-
this.getPath('/viewer/json/compute?enums=true'),
236-
{sort, ...params},
237-
{concurrentId, requestConfig: {signal}},
238-
);
239-
}
240226
getStorageInfo(
241227
{tenant, database, nodeId, groupId, pDiskId, ...params}: StorageRequestParams,
242228
{concurrentId, signal}: AxiosOptions = {},

src/services/settings.ts

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
THEME_KEY,
2222
USE_ADVANCED_STORAGE_KEY,
2323
USE_CLUSTER_BALANCER_AS_BACKEND_KEY,
24-
USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
2524
USE_PAGINATED_TABLES_KEY,
2625
} from '../utils/constants';
2726
import {QUERY_ACTIONS} from '../utils/query';
@@ -34,7 +33,6 @@ export const DEFAULT_USER_SETTINGS = {
3433
[THEME_KEY]: 'system',
3534
[LANGUAGE_KEY]: undefined,
3635
[INVERTED_DISKS_KEY]: false,
37-
[USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY]: true,
3836
[USE_ADVANCED_STORAGE_KEY]: false,
3937
[QUERY_USE_MULTI_SCHEMA_KEY]: true,
4038
[BINARY_DATA_IN_PLAIN_TEXT_DISPLAY]: true,

src/store/reducers/nodes/nodes.ts

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {api} from '../api';
22

3-
import type {ComputeApiRequestParams, NodesApiRequestParams} from './types';
4-
import {prepareComputeNodesData, prepareNodesData} from './utils';
3+
import type {NodesApiRequestParams} from './types';
4+
import {prepareNodesData} from './utils';
55

66
export const nodesApi = api.injectEndpoints({
77
endpoints: (builder) => ({
@@ -24,23 +24,6 @@ export const nodesApi = api.injectEndpoints({
2424
},
2525
providesTags: ['All'],
2626
}),
27-
getComputeNodes: builder.query({
28-
queryFn: async (params: ComputeApiRequestParams, {signal}) => {
29-
try {
30-
const data = await window.api.getCompute(
31-
{
32-
version: 'v2',
33-
...params,
34-
},
35-
{signal},
36-
);
37-
return {data: prepareComputeNodesData(data)};
38-
} catch (error) {
39-
return {error};
40-
}
41-
},
42-
providesTags: ['All'],
43-
}),
4427
}),
4528
overrideExisting: 'throw',
4629
});

src/store/reducers/nodes/types.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import type {OrderType} from '@gravity-ui/react-data-table';
22

3-
import type {
4-
EVersion,
5-
TTabletStateInfo as TComputeTabletStateInfo,
6-
} from '../../../types/api/compute';
73
import type {EFlag} from '../../../types/api/enums';
84
import type {TEndpoint, TPoolStats} from '../../../types/api/nodes';
95
import type {TTabletStateInfo as TFullTabletStateInfo} from '../../../types/api/tablet';
@@ -36,7 +32,7 @@ export interface NodesPreparedEntity {
3632
PoolStats?: TPoolStats[];
3733
LoadAverage?: number[];
3834
LoadAveragePercents?: number[];
39-
Tablets?: TFullTabletStateInfo[] | TComputeTabletStateInfo[];
35+
Tablets?: TFullTabletStateInfo[];
4036
Endpoints?: TEndpoint[];
4137

4238
TotalSessions?: number;
@@ -79,11 +75,6 @@ export interface NodesApiRequestParams extends NodesGeneralRequestParams {
7975
group?: string;
8076
}
8177

82-
export interface ComputeApiRequestParams extends NodesGeneralRequestParams {
83-
path: string;
84-
version?: EVersion; // only v2 works with filters
85-
}
86-
8778
export interface NodesGroup {
8879
name: string;
8980
count: number;

src/store/reducers/nodes/utils.ts

+2-48
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,8 @@
1-
import type {TComputeInfo, TComputeNodeInfo, TComputeTenantInfo} from '../../../types/api/compute';
21
import type {TNodesInfo} from '../../../types/api/nodes';
3-
import {calcUptime} from '../../../utils/dataFormatters/dataFormatters';
42
import {generateEvaluator} from '../../../utils/generateEvaluator';
5-
import {calculateLoadAveragePercents, prepareNodeSystemState} from '../../../utils/nodes';
3+
import {prepareNodeSystemState} from '../../../utils/nodes';
64

7-
import type {NodesHandledResponse, NodesPreparedEntity} from './types';
8-
9-
const prepareComputeNode = (node: TComputeNodeInfo, tenantName?: string): NodesPreparedEntity => {
10-
return {
11-
...node,
12-
// v2 response has tenant name, v1 - doesn't
13-
TenantName: node.Tenant ?? tenantName,
14-
SystemState: node?.Overall,
15-
Uptime: calcUptime(node?.StartTime),
16-
LoadAveragePercents: calculateLoadAveragePercents(node),
17-
18-
DC: node.DataCenter,
19-
};
20-
};
21-
22-
export const prepareComputeNodes = (nodes?: TComputeNodeInfo[], tenants?: TComputeTenantInfo[]) => {
23-
const preparedNodes: NodesPreparedEntity[] = [];
24-
25-
// First try to parse v2 response in case backend supports it
26-
// Else parse v1 response
27-
28-
if (nodes) {
29-
nodes.forEach((node) => {
30-
preparedNodes.push(prepareComputeNode(node));
31-
});
32-
} else if (tenants) {
33-
for (const tenant of tenants) {
34-
tenant.Nodes?.forEach((node) => {
35-
preparedNodes.push(prepareComputeNode(node, tenant.Name));
36-
});
37-
}
38-
}
39-
40-
return preparedNodes;
41-
};
42-
43-
export const prepareComputeNodesData = (data: TComputeInfo): NodesHandledResponse => {
44-
const preparedNodes = prepareComputeNodes(data.Nodes, data.Tenants);
45-
46-
return {
47-
Nodes: preparedNodes,
48-
TotalNodes: Number(data.TotalNodes) || preparedNodes.length,
49-
FoundNodes: Number(data.FoundNodes),
50-
};
51-
};
5+
import type {NodesHandledResponse} from './types';
526

537
export const prepareNodesData = (data: TNodesInfo): NodesHandledResponse => {
548
const rawNodes = data.Nodes || [];

src/types/api/compute.ts

-64
This file was deleted.

src/utils/constants.ts

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export const TENANT_DEFAULT_TITLE = 'Database';
8989
export const THEME_KEY = 'theme';
9090
export const LANGUAGE_KEY = 'language';
9191
export const INVERTED_DISKS_KEY = 'invertedDisks';
92-
export const USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY = 'useNodesEndpointInDiagnostics';
9392
export const SAVED_QUERIES_KEY = 'saved_queries';
9493
export const ASIDE_HEADER_COMPACT_KEY = 'asideHeaderCompact';
9594
export const QUERIES_HISTORY_KEY = 'queries_history';

src/utils/nodes.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {z} from 'zod';
33
import type {NodesPreparedEntity} from '../store/reducers/nodes/types';
44
import {ProblemFilterValues} from '../store/reducers/settings/settings';
55
import type {ProblemFilterValue} from '../store/reducers/settings/types';
6-
import type {TComputeNodeInfo} from '../types/api/compute';
76
import {EFlag} from '../types/api/enums';
87
import type {TSystemStateInfo} from '../types/api/nodes';
98
import type {TNodeInfo} from '../types/api/nodesList';
@@ -41,7 +40,7 @@ export const prepareNodesMap = (nodesList?: TNodeInfo[]) => {
4140
}, new Map());
4241
};
4342

44-
export function calculateLoadAveragePercents(node: TSystemStateInfo | TComputeNodeInfo = {}) {
43+
export function calculateLoadAveragePercents(node: TSystemStateInfo = {}) {
4544
const {LoadAverage, NumberOfCpus} = node;
4645

4746
if (!valueIsDefined(LoadAverage) || !valueIsDefined(NumberOfCpus)) {

0 commit comments

Comments
 (0)