Skip to content
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

feat: show transfer errors in UI #2043

Merged
merged 2 commits into from
Mar 26, 2025
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
4 changes: 3 additions & 1 deletion src/containers/Tenant/Diagnostics/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ function Overview({type, path, database}: OverviewProps) {
[EPathType.EPathTypeExternalDataSource]: () => <ExternalDataSourceInfo data={data} />,
[EPathType.EPathTypeView]: () => <ViewInfo data={data} />,
[EPathType.EPathTypeReplication]: () => <AsyncReplicationInfo data={data} />,
[EPathType.EPathTypeTransfer]: () => <TransferInfo data={data} />,
[EPathType.EPathTypeTransfer]: () => (
<TransferInfo path={path} database={database} data={data} />
),
};

return (type && pathTypeToComponent[type]?.()) || <TableInfo data={data} type={type} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ import {Flex, Text} from '@gravity-ui/uikit';
import {AsyncReplicationState} from '../../../../../components/AsyncReplicationState';
import {YDBSyntaxHighlighter} from '../../../../../components/SyntaxHighlighter/YDBSyntaxHighlighter';
import {YDBDefinitionList} from '../../../../../components/YDBDefinitionList/YDBDefinitionList';
import {replicationApi} from '../../../../../store/reducers/replication';
import type {DescribeReplicationResult} from '../../../../../types/api/replication';
import type {TEvDescribeSchemeResult} from '../../../../../types/api/schema';
import {getEntityName} from '../../../utils';

import {Credentials} from './Credentials';
import i18n from './i18n';

interface TransferProps {
path: string;
database: string;
data?: TEvDescribeSchemeResult;
}

/** Displays overview for Transfer EPathType */
export function TransferInfo({data}: TransferProps) {
export function TransferInfo({path, database, data}: TransferProps) {
const entityName = getEntityName(data?.PathDescription);

if (!data) {
Expand All @@ -26,7 +30,8 @@ export function TransferInfo({data}: TransferProps) {
);
}

const transferItems = prepareTransferItems(data);
const {data: replicationData} = replicationApi.useGetReplicationQuery({path, database}, {});
const transferItems = prepareTransferItems(data, replicationData);

return (
<Flex direction="column" gap="4">
Expand All @@ -35,7 +40,10 @@ export function TransferInfo({data}: TransferProps) {
);
}

function prepareTransferItems(data: TEvDescribeSchemeResult) {
function prepareTransferItems(
data: TEvDescribeSchemeResult,
replicationData: DescribeReplicationResult | undefined,
) {
const transferDescription = data.PathDescription?.ReplicationDescription || {};
const state = transferDescription.State;
const srcConnectionParams = transferDescription.Config?.SrcConnectionParams || {};
Expand All @@ -54,6 +62,18 @@ function prepareTransferItems(data: TEvDescribeSchemeResult) {
});
}

if (replicationData?.error?.issues && replicationData.error.issues[0]?.message) {
info.push({
name: i18n('state.error'),
copyText: replicationData.error.issues[0].message,
content: (
<Text variant="code-inline-2" color="danger">
{replicationData.error.issues[0].message}
</Text>
),
});
}

if (Endpoint) {
info.push({
name: i18n('srcConnection.endpoint.label'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"srcConnection.database.label": "Source Database Path",
"srcConnection.endpoint.label": "Source Cluster Endpoint",
"state.label": "State",
"state.error": "Error",
"srcPath.label": "Source Topic",
"dstPath.label": "Destination Table",
"transformLambda.label": "Transformation Lambda"
Expand Down
17 changes: 17 additions & 0 deletions src/services/api/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
SendQueryParams,
} from '../../types/api/query';
import type {JsonRenderRequestParams, JsonRenderResponse} from '../../types/api/render';
import type {DescribeReplicationResult} from '../../types/api/replication';
import type {TEvDescribeSchemeResult} from '../../types/api/schema';
import type {StorageRequestParams, TStorageInfo} from '../../types/api/storage';
import type {TEvSystemStateResponse} from '../../types/api/systemState';
Expand Down Expand Up @@ -229,6 +230,22 @@ export class ViewerAPI extends BaseYdbAPI {
);
}

getReplication(
{path, database}: {path: string; database: string},
{concurrentId, signal}: AxiosOptions = {},
) {
return this.get<DescribeReplicationResult>(
this.getPath('/viewer/json/describe_replication'),
{
enums: true,
include_stats: true,
database,
path,
},
{concurrentId, requestConfig: {signal}},
);
}

getTopic(
{path, database}: {path: string; database: string},
{concurrentId, signal}: AxiosOptions = {},
Expand Down
22 changes: 22 additions & 0 deletions src/store/reducers/replication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {api} from './api';

export const replicationApi = api.injectEndpoints({
endpoints: (build) => ({
getReplication: build.query({
queryFn: async (params: {path: string; database: string}) => {
try {
const data = await window.api.viewer.getReplication(params);
// On older version it can return HTML page of Developer UI with an error
if (typeof data !== 'object') {
return {error: {}};
}
return {data};
} catch (error) {
return {error};
}
},
providesTags: ['All'],
}),
}),
overrideExisting: 'throw',
});
31 changes: 31 additions & 0 deletions src/types/api/replication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable camelcase */

import type {TIssueMessage} from './operations';

/**
* endpoint: /json/describe_replication
*
* source: https://github.com/ydb-platform/ydb/blob/main/ydb/public/api/protos/draft/ydb_replication.proto
*
* Original proto file doesn't specify optional fields, so every field is considered optional
*/
export interface DescribeReplicationResult {
items?: TReplicationItems;

error?: TReplicationErrorState;
}

export interface TReplicationErrorState {
issues?: TIssueMessage[];
}

export interface TReplicationItems {
items?: TReplicationItem[];
}

export interface TReplicationItem {
id?: string;
source_path?: string;
destination_path?: string;
source_changefeed_name?: string;
}
Loading