Skip to content

Commit e452f15

Browse files
authored
fix(Tablet): remove nodeId from header and api requests for tablet (#1461)
1 parent 75063e6 commit e452f15

File tree

6 files changed

+15
-47
lines changed

6 files changed

+15
-47
lines changed

src/containers/Header/breadcrumbs.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,11 @@ const getStorageGroupBreadcrumbs: GetBreadcrumbs<StorageGroupBreadcrumbsOptions>
178178
};
179179

180180
const getTabletBreadcrumbs: GetBreadcrumbs<TabletBreadcrumbsOptions> = (options, query = {}) => {
181-
const {tabletId, tabletType, nodeId, nodeRole, nodeActiveTab = TABLETS, tenantName} = options;
181+
const {tabletId, tabletType, tenantName} = options;
182182

183-
const breadcrumbs = getNodeBreadcrumbs({nodeId, nodeRole, nodeActiveTab, tenantName}, query);
183+
const breadcrumbs = tenantName
184+
? getTenantBreadcrumbs(options, query)
185+
: getClusterBreadcrumbs(options, query);
184186

185187
const lastItem = {
186188
text: tabletId || headerKeyset('breadcrumbs.tablet'),

src/containers/Tablet/Tablet.tsx

+5-35
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ import {PageMetaWithAutorefresh} from '../../components/PageMeta/PageMeta';
1616
import {getTabletPagePath} from '../../routes';
1717
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
1818
import {setHeaderBreadcrumbs} from '../../store/reducers/header/header';
19-
import {nodeApi} from '../../store/reducers/node/node';
2019
import {tabletApi} from '../../store/reducers/tablet';
2120
import {EFlag} from '../../types/api/enums';
2221
import type {TTabletStateInfo} from '../../types/api/tablet';
23-
import {EType} from '../../types/api/tablet';
2422
import type {ITabletPreparedHistoryItem} from '../../types/store/tablet';
2523
import {cn} from '../../utils/cn';
2624
import {CLUSTER_DEFAULT_TITLE} from '../../utils/constants';
@@ -59,12 +57,9 @@ const TABLET_PAGE_TABS = [
5957
];
6058

6159
const tabletTabSchema = z.nativeEnum(TABLET_TABS_IDS).catch(TABLET_TABS_IDS.history);
62-
const eTypeSchema = z.nativeEnum(EType).or(z.undefined()).catch(undefined);
6360

6461
const tabletQueryParams = {
65-
nodeId: StringParam,
6662
tenantName: StringParam,
67-
type: StringParam,
6863
clusterName: StringParam,
6964
activeTab: StringParam,
7065
};
@@ -74,18 +69,12 @@ export function Tablet() {
7469

7570
const {id} = useParams<{id: string}>();
7671

77-
const [
78-
{
79-
nodeId: queryNodeId,
80-
tenantName: queryDatabase,
81-
type: queryTabletType,
82-
clusterName: queryClusterName,
83-
},
84-
] = useQueryParams(tabletQueryParams);
72+
const [{tenantName: queryDatabase, clusterName: queryClusterName}] =
73+
useQueryParams(tabletQueryParams);
8574

8675
const [autoRefreshInterval] = useAutoRefreshInterval();
8776
const {currentData, isFetching, error} = tabletApi.useGetTabletQuery(
88-
{id, database: queryDatabase ?? undefined, nodeId: queryNodeId ?? undefined},
77+
{id, database: queryDatabase ?? undefined},
8978
{pollingInterval: autoRefreshInterval},
9079
);
9180

@@ -96,24 +85,19 @@ export function Tablet() {
9685
tablet.TenantId ? {tenantId: tablet.TenantId} : skipToken,
9786
);
9887

99-
const nodeId = tablet.NodeId ?? queryNodeId ?? undefined;
10088
const database = (tenantPath || queryDatabase) ?? undefined;
10189

102-
const nodeRole = useNodeRole(nodeId?.toString());
103-
104-
const tabletType = tablet.Type || eTypeSchema.parse(queryTabletType);
90+
const tabletType = tablet.Type;
10591

10692
React.useEffect(() => {
10793
dispatch(
10894
setHeaderBreadcrumbs('tablet', {
109-
nodeId,
110-
nodeRole,
11195
tenantName: queryDatabase ?? undefined,
11296
tabletId: id,
11397
tabletType,
11498
}),
11599
);
116-
}, [dispatch, queryDatabase, id, nodeId, nodeRole, tabletType]);
100+
}, [dispatch, queryDatabase, id, tabletType]);
117101

118102
const {Leader, Type} = tablet;
119103
const metaItems: string[] = [];
@@ -246,17 +230,3 @@ function Channels({id, hiveId}: {id: string; hiveId: string}) {
246230
</LoaderWrapper>
247231
);
248232
}
249-
250-
function useNodeRole(nodeId: string | undefined) {
251-
const {currentData: node} = nodeApi.useGetNodeInfoQuery(nodeId ? {nodeId} : skipToken);
252-
253-
let nodeRole: 'Storage' | 'Compute' | undefined;
254-
255-
if (node) {
256-
// Compute nodes have tenantName, storage nodes doesn't
257-
const isStorage = !node?.Tenants?.[0];
258-
nodeRole = isStorage ? 'Storage' : 'Compute';
259-
}
260-
261-
return nodeRole;
262-
}

src/containers/Tablets/TabletsTable.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ function getColumns({database}: {database?: string}) {
5151
}
5252

5353
const tabletPath = getTabletPagePath(row.TabletId, {
54-
nodeId: row.NodeId,
55-
type: row.Type,
5654
tenantName: database,
5755
});
5856

src/services/api.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -467,15 +467,14 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
467467
);
468468
}
469469
getTablet(
470-
{id, database, nodeId}: {id: string; database?: string; nodeId?: string},
470+
{id, database}: {id: string; database?: string},
471471
{concurrentId, signal}: AxiosOptions = {},
472472
) {
473473
return this.get<TEvTabletStateResponse>(
474474
this.getPath('/viewer/json/tabletinfo'),
475475
{
476476
enums: true,
477477
database,
478-
node_id: nodeId,
479478
filter: `(TabletId=${id})`,
480479
},
481480
{
@@ -485,7 +484,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
485484
);
486485
}
487486
getTabletHistory(
488-
{id, database, nodeId}: {id: string; database?: string; nodeId?: string},
487+
{id, database}: {id: string; database?: string},
489488
{concurrentId, signal}: AxiosOptions = {},
490489
) {
491490
return this.get<UnmergedTEvTabletStateResponse>(
@@ -494,7 +493,6 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
494493
enums: true,
495494
merge: false,
496495
database,
497-
node_id: nodeId,
498496
filter: `(TabletId=${id})`,
499497
},
500498
{

src/store/reducers/header/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface VDiskBreadcrumbsOptions extends PDiskBreadcrumbsOptions {
4141
vDiskSlotId?: string | number;
4242
}
4343

44-
export interface TabletBreadcrumbsOptions extends NodeBreadcrumbsOptions {
44+
export interface TabletBreadcrumbsOptions extends TenantBreadcrumbsOptions {
4545
tabletId?: string;
4646
tabletType?: EType;
4747
}

src/store/reducers/tablet.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ export const tabletApi = api.injectEndpoints({
88
endpoints: (build) => ({
99
getTablet: build.query({
1010
queryFn: async (
11-
{id, database, nodeId}: {id: string; database?: string; nodeId?: string},
11+
{id, database}: {id: string; database?: string; nodeId?: string},
1212
{signal},
1313
) => {
1414
try {
1515
const [tabletResponseData, historyResponseData, nodesList] = await Promise.all([
16-
window.api.getTablet({id, database, nodeId}, {signal}),
17-
window.api.getTabletHistory({id, database, nodeId}, {signal}),
16+
window.api.getTablet({id, database}, {signal}),
17+
window.api.getTabletHistory({id, database}, {signal}),
1818
window.api.getNodesList({signal}),
1919
]);
2020
const nodeHostsMap = prepareNodeHostsMap(nodesList);

0 commit comments

Comments
 (0)