Skip to content

Commit 4b395d2

Browse files
authored
[8.18] [Upgrade Assistant] [Core] Data streams readonly flow (#209562) (#210302)
# Backport This will backport the following commits from `8.x` to `8.18`: - [[Upgrade Assistant] [Core] Data streams readonly flow (#209562)](#209562) <!--- Backport version: 9.6.4 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ahmad Bamieh","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-09T16:45:18Z","message":"[Upgrade Assistant] [Core] Data streams readonly flow (#209562)\n\n## Data streams readonly flow\r\n\r\nImplement marking data streams as read only in addition to the already\r\nexisting reindex flow.\r\n\r\n---------\r\n\r\nCo-authored-by: Jean-Louis Leysens <[email protected]>","sha":"9afc910ac4c31d90e993cfd7d06657a67a738fdc","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","v9.0.0","v8.18.0","v8.19.0"],"title":"[Upgrade Assistant] [Core] Data streams readonly flow","number":209562,"url":"https://github.com/elastic/kibana/pull/209562","mergeCommit":{"message":"[Upgrade Assistant] [Core] Data streams readonly flow (#209562)\n\n## Data streams readonly flow\r\n\r\nImplement marking data streams as read only in addition to the already\r\nexisting reindex flow.\r\n\r\n---------\r\n\r\nCo-authored-by: Jean-Louis Leysens <[email protected]>","sha":"9afc910ac4c31d90e993cfd7d06657a67a738fdc"}},"sourceBranch":"8.x","suggestedTargetBranches":["9.0","8.18"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
1 parent 45f6001 commit 4b395d2

35 files changed

+1292
-761
lines changed

x-pack/platform/plugins/private/upgrade_assistant/common/data_stream_types.ts

+16-14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface DataStreamsActionMetadata {
1414
reindexRequired: boolean;
1515
}
1616

17+
export type DataStreamResolutionType = 'readonly' | 'reindex';
1718
export interface DataStreamsAction {
1819
type: 'dataStream';
1920
metadata: DataStreamsActionMetadata;
@@ -34,21 +35,22 @@ export interface DataStreamMetadata {
3435
}
3536

3637
export interface DataStreamReindexStatusResponse {
37-
warnings?: DataStreamReindexWarning[];
38-
reindexOp?: DataStreamReindexOperation;
38+
warnings?: DataStreamMigrationWarning[];
39+
migrationOp?: DataStreamMigrationOperation;
3940
hasRequiredPrivileges?: boolean;
4041
}
4142

42-
export type DataStreamReindexWarningTypes = 'incompatibleDataStream';
43+
export type DataStreamWarningTypes = 'incompatibleDataStream' | 'affectExistingSetups';
4344

44-
export interface DataStreamReindexWarning {
45-
warningType: DataStreamReindexWarningTypes;
45+
export interface DataStreamMigrationWarning {
46+
warningType: DataStreamWarningTypes;
47+
resolutionType: DataStreamResolutionType;
4648
meta?: {
4749
[key: string]: string | string[];
4850
};
4951
}
5052

51-
export enum DataStreamReindexStatus {
53+
export enum DataStreamMigrationStatus {
5254
notStarted,
5355
inProgress,
5456
completed,
@@ -66,31 +68,31 @@ export interface DataStreamProgressDetails {
6668
}
6769

6870
export interface DataStreamReindexStatusNotStarted {
69-
status: DataStreamReindexStatus.notStarted;
71+
status: DataStreamMigrationStatus.notStarted;
7072
}
7173

7274
export interface DataStreamReindexStatusInProgress {
73-
status: DataStreamReindexStatus.inProgress;
74-
reindexTaskPercComplete: number;
75+
status: DataStreamMigrationStatus.inProgress;
76+
taskPercComplete: number;
7577
progressDetails: DataStreamProgressDetails;
7678
}
7779

7880
export interface DataStreamReindexStatusCompleted {
79-
status: DataStreamReindexStatus.completed;
80-
reindexTaskPercComplete: number;
81+
status: DataStreamMigrationStatus.completed;
82+
taskPercComplete: number;
8183
progressDetails: DataStreamProgressDetails;
8284
}
8385

8486
export interface DataStreamReindexStatusFailed {
85-
status: DataStreamReindexStatus.failed;
87+
status: DataStreamMigrationStatus.failed;
8688
errorMessage: string;
8789
}
8890

8991
export interface DataStreamReindexStatusCancelled {
90-
status: DataStreamReindexStatus.cancelled;
92+
status: DataStreamMigrationStatus.cancelled;
9193
}
9294

93-
export type DataStreamReindexOperation =
95+
export type DataStreamMigrationOperation =
9496
| DataStreamReindexStatusNotStarted
9597
| DataStreamReindexStatusInProgress
9698
| DataStreamReindexStatusCompleted

x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/data_streams/context.tsx

+33-13
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,31 @@
88
import React, { createContext, useContext } from 'react';
99

1010
import { ApiService } from '../../../../lib/api';
11-
import { useReindexStatus, ReindexState } from './use_reindex_state';
11+
import { useMigrationStatus, MigrationState } from './use_migration_state';
12+
import type { DataStreamResolutionType } from '../../../../../../common/types';
1213

13-
export interface ReindexStateContext {
14-
reindexState: ReindexState;
15-
startReindex: () => Promise<void>;
14+
export interface MigrationStateContext {
1615
loadDataStreamMetadata: () => Promise<void>;
16+
migrationState: MigrationState;
17+
18+
initMigration: (resolutionType: DataStreamResolutionType) => void;
19+
20+
// reindex resolution actions
21+
startReindex: () => Promise<void>;
1722
cancelReindex: () => Promise<void>;
23+
24+
// readonly resolution actions
25+
startReadonly: () => Promise<void>;
26+
cancelReadonly: () => Promise<void>;
1827
}
1928

20-
const DataStreamReindexContext = createContext<ReindexStateContext | undefined>(undefined);
29+
const DataStreamMigrationContext = createContext<MigrationStateContext | undefined>(undefined);
2130

22-
export const useDataStreamReindexContext = () => {
23-
const context = useContext(DataStreamReindexContext);
31+
export const useDataStreamMigrationContext = () => {
32+
const context = useContext(DataStreamMigrationContext);
2433
if (context === undefined) {
2534
throw new Error(
26-
'useDataStreamReindexContext must be used within a <DataStreamReindexStatusProvider />'
35+
'useDataStreamMigrationContext must be used within a <DataStreamMigrationStatusProvider />'
2736
);
2837
}
2938
return context;
@@ -35,26 +44,37 @@ interface Props {
3544
dataStreamName: string;
3645
}
3746

38-
export const DataStreamReindexStatusProvider: React.FunctionComponent<Props> = ({
47+
export const DataStreamMigrationStatusProvider: React.FunctionComponent<Props> = ({
3948
api,
4049
dataStreamName,
4150
children,
4251
}) => {
43-
const { reindexState, startReindex, loadDataStreamMetadata, cancelReindex } = useReindexStatus({
52+
const {
53+
migrationState,
54+
cancelReadonly,
55+
startReindex,
56+
loadDataStreamMetadata,
57+
cancelReindex,
58+
startReadonly,
59+
initMigration,
60+
} = useMigrationStatus({
4461
dataStreamName,
4562
api,
4663
});
4764

4865
return (
49-
<DataStreamReindexContext.Provider
66+
<DataStreamMigrationContext.Provider
5067
value={{
51-
reindexState,
68+
migrationState,
5269
startReindex,
5370
cancelReindex,
71+
startReadonly,
72+
cancelReadonly,
73+
initMigration,
5474
loadDataStreamMetadata,
5575
}}
5676
>
5777
{children}
58-
</DataStreamReindexContext.Provider>
78+
</DataStreamMigrationContext.Provider>
5979
);
6080
};

0 commit comments

Comments
 (0)