Skip to content

feat: remove /meta/cluster #1757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ClipboardButton} from '@gravity-ui/uikit';

import {useClusterBaseInfo} from '../../../store/reducers/cluster/cluster';
import type {
AdditionalClusterProps,
AdditionalTenantsProps,
Expand Down Expand Up @@ -122,27 +123,22 @@ export function ExtendedCluster({
getMonitoringLink,
getMonitoringClusterLink,
}: ExtendedClusterProps) {
const {
monitoring,
balancer,
versions,
cluster,
useClusterBalancerAsBackend,
additionalNodesProps,
} = useClusterData();
const {versions, useClusterBalancerAsBackend, additionalNodesProps} = useClusterData();

const {name, balancer, monitoring} = useClusterBaseInfo();

return (
<div className={b()}>
<ClusterComponent
additionalClusterProps={getAdditionalClusterProps(
cluster?.Name,
name,
monitoring,
balancer,
getMonitoringClusterLink,
)}
additionalVersionsProps={getAdditionalVersionsProps(versions)}
additionalTenantsProps={getAdditionalTenantsProps(
cluster?.Name,
name,
monitoring,
balancer,
useClusterBalancerAsBackend,
Expand Down
3 changes: 1 addition & 2 deletions src/containers/AppWithClusters/useClusterData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ export function useClusterData() {
return clusters.find((cluster) => cluster.name === clusterName);
}, [data, clusterName]);

const {solomon: monitoring, balancer, versions, cluster} = info || {};
const {solomon: monitoring, balancer, versions} = info || {};

return {
monitoring,
balancer,
versions,
cluster,
...useAdditionalNodeProps({balancer}),
};
}
Expand Down
7 changes: 6 additions & 1 deletion src/containers/Cluster/Cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
selectClusterTabletsWithFqdn,
selectClusterTitle,
updateDefaultClusterTab,
useClusterBaseInfo,
} from '../../store/reducers/cluster/cluster';
import {setHeaderBreadcrumbs} from '../../store/reducers/header/header';
import type {
Expand Down Expand Up @@ -66,10 +67,14 @@ export function Cluster({
backend: StringParam,
});

const clusterTitle = useTypedSelector((state) =>
const viewerClusterTitle = useTypedSelector((state) =>
selectClusterTitle(state, clusterName ?? undefined),
);

const {title: metaClusterTitle} = useClusterBaseInfo();

const clusterTitle = metaClusterTitle ?? viewerClusterTitle;

const {
data: {clusterData: cluster = {}, groupsStats} = {},
isLoading: infoLoading,
Expand Down
12 changes: 0 additions & 12 deletions src/services/api/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import {metaBackend as META_BACKEND} from '../../store';
import type {
MetaBaseClusterInfo,
MetaBaseClusters,
MetaCluster,
MetaClusters,
MetaTenants,
} from '../../types/api/meta';
import {parseMetaCluster} from '../parsers/parseMetaCluster';
import {parseMetaTenants} from '../parsers/parseMetaTenants';

import type {AxiosOptions} from './base';
Expand All @@ -23,16 +21,6 @@ export class MetaAPI extends BaseYdbAPI {
});
}

getClusterInfo(clusterName?: string, {signal}: AxiosOptions = {}) {
return this.get<MetaCluster>(
this.getPath('/meta/cluster'),
{
name: clusterName,
},
{concurrentId: `getCluster${clusterName}`, requestConfig: {signal}},
).then(parseMetaCluster);
}

getTenants(clusterName?: string, {signal}: AxiosOptions = {}) {
return this.get<MetaTenants>(
this.getPath('/meta/cp_databases'),
Expand Down
29 changes: 0 additions & 29 deletions src/services/parsers/parseMetaCluster.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
import type {TClusterInfo} from '../../types/api/cluster';
import type {MetaCluster} from '../../types/api/meta';
import {traceCheckSchema, traceViewSchema} from '../../types/api/trace';

export const parseMetaCluster = (data: MetaCluster): TClusterInfo => {
const {cluster = {}} = data;

const {
cluster: generalClusterInfo,
balancer,
solomon,
trace_check: traceCheck,
trace_view: traceView,
} = cluster;

const {traceCheck: TraceCheck, traceView: TraceView} = parseTraceFields({
traceCheck,
traceView,
});

return {
...generalClusterInfo,
Name: cluster.title || generalClusterInfo?.Name,

Balancer: balancer,
Solomon: solomon,
TraceCheck,
TraceView,
};
};

export function parseTraceFields({
traceCheck,
traceView,
Expand Down
14 changes: 8 additions & 6 deletions src/store/reducers/cluster/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export const clusterApi = api.injectEndpoints({
>({
queryFn: async (clusterName, {signal}) => {
try {
const clusterData = window.api.meta
? await window.api.meta.getClusterInfo(clusterName, {signal})
: await window.api.viewer.getClusterInfo(clusterName, {signal});
const clusterData = await window.api.viewer.getClusterInfo(clusterName, {
signal,
});

const clusterRoot = clusterData.Domain;
// Without domain we cannot get stats from system tables
Expand Down Expand Up @@ -171,9 +171,11 @@ export const selectClusterTitle = createSelector(
(_state: RootState, clusterName?: string) => clusterName,
(state: RootState, clusterName?: string) => selectClusterInfo(state, clusterName),
(clusterName, clusterInfo) => {
const {Name, Domain} = clusterInfo?.clusterData || {};

return Name || clusterName || normalizeDomain(Domain) || CLUSTER_DEFAULT_TITLE;
return (
clusterName ||
normalizeDomain(clusterInfo?.clusterData?.Domain) ||
CLUSTER_DEFAULT_TITLE
);
},
);

Expand Down
8 changes: 0 additions & 8 deletions src/types/api/cluster.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {EFlag} from './enums';
import type {TTabletStateInfo} from './tablet';
import type {TTraceCheck, TTraceView} from './trace';

/**
* endpoint: viewer/json/cluster
Expand All @@ -9,7 +8,6 @@ import type {TTraceCheck, TTraceView} from './trace';
*/
export interface TClusterInfoV1 {
error?: string;
Name?: string;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no Name in viewer/cluster response anymore

Overall?: EFlag;
NodesTotal?: number;
NodesAlive?: number;
Expand All @@ -36,12 +34,6 @@ export interface TClusterInfoV1 {

/** Cluster root database */
Domain?: string;

Balancer?: string; // additional
Solomon?: string; // additional

TraceView?: TTraceView;
TraceCheck?: TTraceCheck;
Comment on lines -40 to -44
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields aren't actually present in viewer/cluster response, they were added while parsing meta/cluster

}

export interface TStorageStats {
Expand Down
Loading