diff --git a/src/components/TabletsStatistic/TabletsStatistic.tsx b/src/components/TabletsStatistic/TabletsStatistic.tsx index 37c0bfd9b1..e3c87a1bb8 100644 --- a/src/components/TabletsStatistic/TabletsStatistic.tsx +++ b/src/components/TabletsStatistic/TabletsStatistic.tsx @@ -2,8 +2,7 @@ import {Link} from 'react-router-dom'; import {TABLETS} from '../../containers/Node/NodePages'; import routes, {createHref} from '../../routes'; -import type {TTabletStateInfo as TComputeTabletStateInfo} from '../../types/api/compute'; -import type {TTabletStateInfo as TFullTabletStateInfo} from '../../types/api/tablet'; +import type {TTabletStateInfo} from '../../types/api/tablet'; import {cn} from '../../utils/cn'; import {getTabletLabel} from '../../utils/constants'; import {mapTabletStateToColorState} from '../../utils/tablet'; @@ -12,9 +11,7 @@ import './TabletsStatistic.scss'; const b = cn('tablets-statistic'); -type Tablets = TFullTabletStateInfo[] | TComputeTabletStateInfo[]; - -const prepareTablets = (tablets: Tablets) => { +const prepareTablets = (tablets: TTabletStateInfo[]) => { const res = tablets.map((tablet) => { return { label: getTabletLabel(tablet.Type), @@ -28,7 +25,7 @@ const prepareTablets = (tablets: Tablets) => { }; interface TabletsStatisticProps { - tablets: Tablets; + tablets: TTabletStateInfo[]; path: string | undefined; nodeId: string | number; backend?: string; diff --git a/src/containers/Nodes/Nodes.tsx b/src/containers/Nodes/Nodes.tsx index b0e7c8d6c7..f2517ac2fa 100644 --- a/src/containers/Nodes/Nodes.tsx +++ b/src/containers/Nodes/Nodes.tsx @@ -1,7 +1,6 @@ import React from 'react'; import {ASCENDING} from '@gravity-ui/react-data-table/build/esm/lib/constants'; -import {skipToken} from '@reduxjs/toolkit/query'; import {StringParam, useQueryParams} from 'use-query-params'; import {EntitiesCount} from '../../components/EntitiesCount'; @@ -25,10 +24,9 @@ import { import type {ProblemFilterValue} from '../../store/reducers/settings/types'; import type {AdditionalNodesProps} from '../../types/additionalProps'; import {cn} from '../../utils/cn'; -import {DEFAULT_TABLE_SETTINGS, USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY} from '../../utils/constants'; +import {DEFAULT_TABLE_SETTINGS} from '../../utils/constants'; import { useAutoRefreshInterval, - useSetting, useTableSort, useTypedDispatch, useTypedSelector, @@ -66,21 +64,11 @@ export const Nodes = ({path, database, additionalNodesProps = {}}: NodesProps) = const problemFilter = useTypedSelector(selectProblemFilter); const [autoRefreshInterval] = useAutoRefreshInterval(); - const [useNodesEndpoint] = useSetting(USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY); - - // If there is no path, it's cluster Nodes tab - const useGetComputeNodes = path && !useNodesEndpoint; - const nodesQuery = nodesApi.useGetNodesQuery( - useGetComputeNodes ? skipToken : {path, database}, - { - pollingInterval: autoRefreshInterval, - }, - ); - const computeQuery = nodesApi.useGetComputeNodesQuery(useGetComputeNodes ? {path} : skipToken, { - pollingInterval: autoRefreshInterval, - }); - - const {currentData: data, isLoading, error} = useGetComputeNodes ? computeQuery : nodesQuery; + const { + currentData: data, + isLoading, + error, + } = nodesApi.useGetNodesQuery({path, database}, {pollingInterval: autoRefreshInterval}); const [sortValue, setSortValue] = React.useState({ sortValue: 'NodeId', diff --git a/src/containers/UserSettings/i18n/en.json b/src/containers/UserSettings/i18n/en.json index 232daaffba..4ebd8d4f9b 100644 --- a/src/containers/UserSettings/i18n/en.json +++ b/src/containers/UserSettings/i18n/en.json @@ -30,9 +30,6 @@ "settings.invertedDisks.title": "Inverted disks space indicators", - "settings.useNodesEndpoint.title": "Break the Nodes tab in Diagnostics", - "settings.useNodesEndpoint.description": "Use /viewer/json/nodes endpoint for Nodes tab in diagnostics. It could return incorrect data on versions before 24-1", - "settings.useAdvancedStorage.title": "Use advanced storage", "settings.useAdvancedStorage.description": "Display additional data in Storage table", diff --git a/src/containers/UserSettings/settings.tsx b/src/containers/UserSettings/settings.tsx index 99eb33f76c..ce8ed90a8e 100644 --- a/src/containers/UserSettings/settings.tsx +++ b/src/containers/UserSettings/settings.tsx @@ -13,7 +13,6 @@ import { THEME_KEY, USE_ADVANCED_STORAGE_KEY, USE_CLUSTER_BALANCER_AS_BACKEND_KEY, - USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY, USE_PAGINATED_TABLES_KEY, } from '../../utils/constants'; import {Lang, defaultLang} from '../../utils/i18n'; @@ -91,11 +90,6 @@ export const invertedDisksSetting: SettingProps = { settingKey: INVERTED_DISKS_KEY, title: i18n('settings.invertedDisks.title'), }; -export const useNodesEndpointSetting: SettingProps = { - settingKey: USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY, - title: i18n('settings.useNodesEndpoint.title'), - description: i18n('settings.useNodesEndpoint.description'), -}; export const useAdvancedStorageSetting: SettingProps = { settingKey: USE_ADVANCED_STORAGE_KEY, title: i18n('settings.useAdvancedStorage.title'), @@ -155,12 +149,7 @@ export const appearanceSection: SettingsSection = { export const experimentsSection: SettingsSection = { id: 'experimentsSection', title: i18n('section.experiments'), - settings: [ - useNodesEndpointSetting, - useAdvancedStorageSetting, - usePaginatedTables, - queryUseMultiSchemaSetting, - ], + settings: [useAdvancedStorageSetting, usePaginatedTables, queryUseMultiSchemaSetting], }; export const devSettingsSection: SettingsSection = { id: 'devSettingsSection', diff --git a/src/services/api.ts b/src/services/api.ts index 84a8a87c39..f5f538ef23 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -4,12 +4,11 @@ import type {AxiosRequestConfig} from 'axios'; import axiosRetry from 'axios-retry'; import {backend as BACKEND, metaBackend as META_BACKEND} from '../store'; -import type {ComputeApiRequestParams, NodesApiRequestParams} from '../store/reducers/nodes/types'; +import type {NodesApiRequestParams} from '../store/reducers/nodes/types'; import type {TMetaInfo} from '../types/api/acl'; import type {TQueryAutocomplete} from '../types/api/autocomplete'; import type {CapabilitiesResponse} from '../types/api/capabilities'; import type {TClusterInfo} from '../types/api/cluster'; -import type {TComputeInfo} from '../types/api/compute'; import type {DescribeConsumerResult} from '../types/api/consumer'; import type {FeatureFlagConfigs} from '../types/api/featureFlags'; import type {HealthCheckAPIResponse} from '../types/api/healthcheck'; @@ -224,19 +223,6 @@ export class YdbEmbeddedAPI extends AxiosWrapper { {concurrentId, requestConfig: {signal}}, ); } - /** @deprecated use getNodes instead */ - getCompute( - {sortOrder, sortValue, ...params}: ComputeApiRequestParams, - {concurrentId, signal}: AxiosOptions = {}, - ) { - const sort = prepareSortValue(sortValue, sortOrder); - - return this.get( - this.getPath('/viewer/json/compute?enums=true'), - {sort, ...params}, - {concurrentId, requestConfig: {signal}}, - ); - } getStorageInfo( {tenant, database, nodeId, groupId, pDiskId, ...params}: StorageRequestParams, {concurrentId, signal}: AxiosOptions = {}, diff --git a/src/services/settings.ts b/src/services/settings.ts index 7cecfc899a..feed25697c 100644 --- a/src/services/settings.ts +++ b/src/services/settings.ts @@ -21,7 +21,6 @@ import { THEME_KEY, USE_ADVANCED_STORAGE_KEY, USE_CLUSTER_BALANCER_AS_BACKEND_KEY, - USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY, USE_PAGINATED_TABLES_KEY, } from '../utils/constants'; import {QUERY_ACTIONS} from '../utils/query'; @@ -34,7 +33,6 @@ export const DEFAULT_USER_SETTINGS = { [THEME_KEY]: 'system', [LANGUAGE_KEY]: undefined, [INVERTED_DISKS_KEY]: false, - [USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY]: true, [USE_ADVANCED_STORAGE_KEY]: false, [QUERY_USE_MULTI_SCHEMA_KEY]: true, [BINARY_DATA_IN_PLAIN_TEXT_DISPLAY]: true, diff --git a/src/store/reducers/nodes/nodes.ts b/src/store/reducers/nodes/nodes.ts index d4d86a3de0..6cd90a9000 100644 --- a/src/store/reducers/nodes/nodes.ts +++ b/src/store/reducers/nodes/nodes.ts @@ -1,7 +1,7 @@ import {api} from '../api'; -import type {ComputeApiRequestParams, NodesApiRequestParams} from './types'; -import {prepareComputeNodesData, prepareNodesData} from './utils'; +import type {NodesApiRequestParams} from './types'; +import {prepareNodesData} from './utils'; export const nodesApi = api.injectEndpoints({ endpoints: (builder) => ({ @@ -24,23 +24,6 @@ export const nodesApi = api.injectEndpoints({ }, providesTags: ['All'], }), - getComputeNodes: builder.query({ - queryFn: async (params: ComputeApiRequestParams, {signal}) => { - try { - const data = await window.api.getCompute( - { - version: 'v2', - ...params, - }, - {signal}, - ); - return {data: prepareComputeNodesData(data)}; - } catch (error) { - return {error}; - } - }, - providesTags: ['All'], - }), }), overrideExisting: 'throw', }); diff --git a/src/store/reducers/nodes/types.ts b/src/store/reducers/nodes/types.ts index 4f970cf90e..9b6f5f58bf 100644 --- a/src/store/reducers/nodes/types.ts +++ b/src/store/reducers/nodes/types.ts @@ -1,9 +1,5 @@ import type {OrderType} from '@gravity-ui/react-data-table'; -import type { - EVersion, - TTabletStateInfo as TComputeTabletStateInfo, -} from '../../../types/api/compute'; import type {EFlag} from '../../../types/api/enums'; import type {TEndpoint, TPoolStats} from '../../../types/api/nodes'; import type {TTabletStateInfo as TFullTabletStateInfo} from '../../../types/api/tablet'; @@ -36,7 +32,7 @@ export interface NodesPreparedEntity { PoolStats?: TPoolStats[]; LoadAverage?: number[]; LoadAveragePercents?: number[]; - Tablets?: TFullTabletStateInfo[] | TComputeTabletStateInfo[]; + Tablets?: TFullTabletStateInfo[]; Endpoints?: TEndpoint[]; TotalSessions?: number; @@ -79,11 +75,6 @@ export interface NodesApiRequestParams extends NodesGeneralRequestParams { group?: string; } -export interface ComputeApiRequestParams extends NodesGeneralRequestParams { - path: string; - version?: EVersion; // only v2 works with filters -} - export interface NodesGroup { name: string; count: number; diff --git a/src/store/reducers/nodes/utils.ts b/src/store/reducers/nodes/utils.ts index abbdf45e4b..273b4ed8e1 100644 --- a/src/store/reducers/nodes/utils.ts +++ b/src/store/reducers/nodes/utils.ts @@ -1,54 +1,8 @@ -import type {TComputeInfo, TComputeNodeInfo, TComputeTenantInfo} from '../../../types/api/compute'; import type {TNodesInfo} from '../../../types/api/nodes'; -import {calcUptime} from '../../../utils/dataFormatters/dataFormatters'; import {generateEvaluator} from '../../../utils/generateEvaluator'; -import {calculateLoadAveragePercents, prepareNodeSystemState} from '../../../utils/nodes'; +import {prepareNodeSystemState} from '../../../utils/nodes'; -import type {NodesHandledResponse, NodesPreparedEntity} from './types'; - -const prepareComputeNode = (node: TComputeNodeInfo, tenantName?: string): NodesPreparedEntity => { - return { - ...node, - // v2 response has tenant name, v1 - doesn't - TenantName: node.Tenant ?? tenantName, - SystemState: node?.Overall, - Uptime: calcUptime(node?.StartTime), - LoadAveragePercents: calculateLoadAveragePercents(node), - - DC: node.DataCenter, - }; -}; - -export const prepareComputeNodes = (nodes?: TComputeNodeInfo[], tenants?: TComputeTenantInfo[]) => { - const preparedNodes: NodesPreparedEntity[] = []; - - // First try to parse v2 response in case backend supports it - // Else parse v1 response - - if (nodes) { - nodes.forEach((node) => { - preparedNodes.push(prepareComputeNode(node)); - }); - } else if (tenants) { - for (const tenant of tenants) { - tenant.Nodes?.forEach((node) => { - preparedNodes.push(prepareComputeNode(node, tenant.Name)); - }); - } - } - - return preparedNodes; -}; - -export const prepareComputeNodesData = (data: TComputeInfo): NodesHandledResponse => { - const preparedNodes = prepareComputeNodes(data.Nodes, data.Tenants); - - return { - Nodes: preparedNodes, - TotalNodes: Number(data.TotalNodes) || preparedNodes.length, - FoundNodes: Number(data.FoundNodes), - }; -}; +import type {NodesHandledResponse} from './types'; export const prepareNodesData = (data: TNodesInfo): NodesHandledResponse => { const rawNodes = data.Nodes || []; diff --git a/src/types/api/compute.ts b/src/types/api/compute.ts deleted file mode 100644 index df33cf4f6f..0000000000 --- a/src/types/api/compute.ts +++ /dev/null @@ -1,64 +0,0 @@ -import type {EFlag} from './enums'; -import type {TEndpoint, TLegacyNodeLocation, TPoolStats} from './nodes'; -import type {TMetrics} from './tenant'; - -/** - * endpoint: viewer/json/compute - * - * source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/viewer/protos/viewer.proto - * - * response has 2 versions, depending on version param in request - */ -export interface TComputeInfo { - Overall: EFlag; - Tenants?: TComputeTenantInfo[]; // v1 - Errors?: string[]; - /** uint64 */ - TotalNodes: string; - /** uint64 */ - FoundNodes: string; - Nodes?: TComputeNodeInfo[]; // v2 -} - -export interface TComputeTenantInfo { - Overall: EFlag; - Name: string; - Nodes?: TComputeNodeInfo[]; -} - -export interface TComputeNodeInfo { - /** uint64 */ - StartTime: string; - /** uint64 */ - ChangeTime: string; - SystemLocation: TLegacyNodeLocation; - /** double */ - LoadAverage: number[]; - NumberOfCpus: number; - Overall: EFlag; - NodeId: number; - DataCenter: string; - Rack: string; - Host: string; - Version: string; - PoolStats?: TPoolStats[]; - Endpoints?: TEndpoint[]; - Roles?: string[]; - /** uint64 */ - MemoryUsed?: string; - /** uint64 */ - MemoryLimit?: string; - Metrics: TMetrics; - Tablets?: TTabletStateInfo[]; - Tenant?: string; // For v2 response without grouping by tenants -} - -// Tablets in compute nodes -// Types for tabletInfo and tablets inside nodes and storage endpoints are in tablet.ts -export interface TTabletStateInfo { - Type: string; - State: EFlag; - Count: number; -} - -export type EVersion = 'v1' | 'v2'; // only v2 versions works with sorting diff --git a/src/utils/constants.ts b/src/utils/constants.ts index ae51f00e4e..92cbea3b3a 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -89,7 +89,6 @@ export const TENANT_DEFAULT_TITLE = 'Database'; export const THEME_KEY = 'theme'; export const LANGUAGE_KEY = 'language'; export const INVERTED_DISKS_KEY = 'invertedDisks'; -export const USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY = 'useNodesEndpointInDiagnostics'; export const SAVED_QUERIES_KEY = 'saved_queries'; export const ASIDE_HEADER_COMPACT_KEY = 'asideHeaderCompact'; export const QUERIES_HISTORY_KEY = 'queries_history'; diff --git a/src/utils/nodes.ts b/src/utils/nodes.ts index 60c7f84bf2..b8de69fc15 100644 --- a/src/utils/nodes.ts +++ b/src/utils/nodes.ts @@ -3,7 +3,6 @@ import {z} from 'zod'; import type {NodesPreparedEntity} from '../store/reducers/nodes/types'; import {ProblemFilterValues} from '../store/reducers/settings/settings'; import type {ProblemFilterValue} from '../store/reducers/settings/types'; -import type {TComputeNodeInfo} from '../types/api/compute'; import {EFlag} from '../types/api/enums'; import type {TSystemStateInfo} from '../types/api/nodes'; import type {TNodeInfo} from '../types/api/nodesList'; @@ -41,7 +40,7 @@ export const prepareNodesMap = (nodesList?: TNodeInfo[]) => { }, new Map()); }; -export function calculateLoadAveragePercents(node: TSystemStateInfo | TComputeNodeInfo = {}) { +export function calculateLoadAveragePercents(node: TSystemStateInfo = {}) { const {LoadAverage, NumberOfCpus} = node; if (!valueIsDefined(LoadAverage) || !valueIsDefined(NumberOfCpus)) {