@camunda/ccma-saas-frontend 0.31.1 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/components/c4-cluster-list/c4-cluster-list.js +3 -1
- package/lib/esm/components/c4-cluster-list/c4-cluster-list.types.d.ts +2 -2
- package/lib/esm/components/c4-cluster-migration/c4-cluster-migration.d.ts +2 -1
- package/lib/esm/components/c4-cluster-migration/c4-cluster-migration.js +46 -15
- package/lib/esm/components/c4-cluster-migration/c4-cluster-migration.types.d.ts +47 -12
- package/lib/esm/components/c4-cluster-migration/migration-translations.d.ts +2 -4
- package/lib/esm/components/c4-cluster-migration/migration-translations.js +90 -15
- package/lib/esm/i18n/en/pages/clusterdetails.json +63 -14
- package/lib/esm/i18n/en/pages/createcluster.json +1 -1
- package/lib/esm/index.d.ts +2 -1
- package/lib/esm/runtime/use-c4-two-phase-upgrade-mockup.d.ts +5 -1
- package/lib/esm/runtime/use-c4-two-phase-upgrade-mockup.js +4 -2
- package/lib/esm/utils/migration-aws-policy.d.ts +22 -0
- package/lib/esm/utils/migration-aws-policy.js +54 -0
- package/lib/esm/utils/migration-view.d.ts +98 -0
- package/lib/esm/utils/migration-view.js +52 -0
- package/lib/esm/utils/migration-workaround.d.ts +46 -32
- package/lib/esm/utils/migration-workaround.js +212 -48
- package/lib/esm/widgets/cluster-details/c4-cluster-details-app.js +50 -40
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-overview-tab.js +3 -2
- package/lib/esm/widgets/clusters/c4-clusters-page.js +8 -7
- package/lib/esm/widgets/create-cluster/c4-create-cluster-page.js +3 -3
- package/package.json +3 -3
- package/lib/esm/components/c4-cluster-migration/backup-id.d.ts +0 -2
- package/lib/esm/components/c4-cluster-migration/backup-id.js +0 -9
|
@@ -342,7 +342,9 @@ export const C4ClusterList = ({ clusters, loading, urls, permissions, onNavigate
|
|
|
342
342
|
label: translations.overflowMenu.delete,
|
|
343
343
|
kind: 'danger--ghost',
|
|
344
344
|
onClick: (row) => onDeleteCluster(row.id),
|
|
345
|
-
visible: (
|
|
345
|
+
visible: () =>
|
|
346
|
+
// Delete stays open: it cancels a migration in every phase.
|
|
347
|
+
permissions.canDeleteCluster,
|
|
346
348
|
},
|
|
347
349
|
];
|
|
348
350
|
const renderDataTable = () => {
|
|
@@ -65,8 +65,8 @@ export interface C4ClusterListProps {
|
|
|
65
65
|
onFailoverCluster?: (clusterId: string) => void;
|
|
66
66
|
onDuplicateCluster?: (clusterId: string) => void;
|
|
67
67
|
/**
|
|
68
|
-
* True hides every row action of the cluster, and the Add tag
|
|
69
|
-
* (migration lock, PDP 3844).
|
|
68
|
+
* True hides every row action of the cluster but Delete, and the Add tag
|
|
69
|
+
* link too (migration lock, PDP 3844).
|
|
70
70
|
*/
|
|
71
71
|
isActionsLocked?: (clusterId: string) => boolean;
|
|
72
72
|
trialNotification?: React.ReactNode;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type JSX } from 'react';
|
|
2
2
|
import type { C4ClusterMigrationProps } from './c4-cluster-migration.types.js';
|
|
3
|
-
|
|
3
|
+
/** The view of a migration that is not complete yet, one panel per phase. */
|
|
4
|
+
export declare function C4ClusterMigration({ migration, busy, canEdit, error, onTransferFinished, onReopenTransfer, onChooseBackup, onDelete, translations: t, }: C4ClusterMigrationProps): JSX.Element;
|
|
@@ -1,24 +1,55 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/*
|
|
3
3
|
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
|
|
4
4
|
* under one or more contributor license agreements. Licensed under a commercial license.
|
|
5
5
|
* You may not use this file except in compliance with the commercial license.
|
|
6
6
|
*/
|
|
7
7
|
import { useState } from 'react';
|
|
8
|
-
import { Button, Checkbox, Stack, TextInput } from '../../ui/index.js';
|
|
8
|
+
import { Button, Checkbox, DsCodeBlock, Stack, TextInput } from '../../ui/index.js';
|
|
9
|
+
import { buildAwsMigrationPolicy, isValidKmsKeyArn, isValidS3BucketName, } from '../../utils/migration-aws-policy.js';
|
|
10
|
+
import { isValidBackupId, isValidPartitionsCount, } from '../../utils/migration-view.js';
|
|
9
11
|
import { C4InlineNotification } from '../c4-inline-notification/c4-inline-notification.js';
|
|
10
|
-
|
|
11
|
-
export function C4ClusterMigration({
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
/** The view of a migration that is not complete yet, one panel per phase. */
|
|
13
|
+
export function C4ClusterMigration({ migration, busy = false, canEdit = true, error, onTransferFinished, onReopenTransfer, onChooseBackup, onDelete, translations: t, }) {
|
|
14
|
+
const { phase } = migration;
|
|
15
|
+
const disabled = busy || !canEdit;
|
|
16
|
+
return (_jsxs(Stack, { gap: 5, "data-testid": `cluster-migration-${phase}`, children: [_jsx("h3", { children: t.title[phase] }), _jsx("p", { "data-testid": 'cluster-migration-reason', children: t.reasonText(phase, migration.reason, migration.reasonParams) }), (phase === 'AwaitingPrincipal' || phase === 'Transferring') && (_jsxs("p", { children: [t.principalLabel, ' ', _jsx("code", { "data-testid": 'cluster-migration-principal', children: migration.spec.principal })] })), phase === 'Transferring' && (_jsx(TransferPanel, { migration: migration, disabled: disabled, onTransferFinished: onTransferFinished, translations: t })), (phase === 'AwaitingBackup' || phase === 'RestoreFailed') && (_jsx(BackupChoicePanel
|
|
17
|
+
// A new phase starts again from the last choice, with an unchecked box.
|
|
18
|
+
, { migration: migration, disabled: disabled, onChooseBackup: onChooseBackup, onReopenTransfer: phase === 'AwaitingBackup' ? onReopenTransfer : undefined, translations: t }, phase)), (phase === 'AwaitingPrincipal' ||
|
|
19
|
+
phase === 'Verifying' ||
|
|
20
|
+
phase === 'Restoring') && (_jsx("p", { "data-testid": 'cluster-migration-progress', children: t.progressText })), phase === 'VerificationFailed' && onDelete && (_jsx("div", { children: _jsx(Button, { kind: 'danger', disabled: busy, onClick: onDelete, children: t.deleteButton }) })), error && (_jsx(C4InlineNotification, { kind: 'error', title: '', subtitle: error, hideCloseButton: true }))] }));
|
|
21
|
+
}
|
|
22
|
+
function TransferPanel({ migration, disabled, onTransferFinished, translations: t, }) {
|
|
23
|
+
const [bucket, setBucket] = useState(migration.source.bucket ?? '');
|
|
24
|
+
const [kmsKeyArn, setKmsKeyArn] = useState(migration.source.kmsKeyArn ?? '');
|
|
25
|
+
// The operator never reads the source bucket. It only adds the source
|
|
26
|
+
// statements to the policy, thus it is optional.
|
|
27
|
+
const bucketValid = bucket === '' || isValidS3BucketName(bucket);
|
|
28
|
+
// The KMS key is only used in the source statements, and these need a
|
|
29
|
+
// bucket. Thus Console ignores the key while the bucket is empty.
|
|
30
|
+
const sourceKmsKeyArn = bucket === '' ? '' : kmsKeyArn;
|
|
31
|
+
const kmsValid = sourceKmsKeyArn === '' || isValidKmsKeyArn(sourceKmsKeyArn);
|
|
32
|
+
const { access } = migration;
|
|
33
|
+
const policy = access
|
|
34
|
+
? buildAwsMigrationPolicy({
|
|
35
|
+
access,
|
|
36
|
+
source: { bucket, kmsKeyArn: sourceKmsKeyArn || undefined },
|
|
37
|
+
principal: migration.spec.principal,
|
|
38
|
+
})
|
|
39
|
+
: undefined;
|
|
40
|
+
return (_jsxs(_Fragment, { children: [_jsx(TextInput, { id: 'cluster-migration-source-bucket', labelText: t.sourceBucketLabel, helperText: t.sourceBucketHelper, value: bucket, invalid: !bucketValid, invalidText: t.sourceBucketInvalid, disabled: disabled, onChange: (event) => setBucket(event.target.value.trim()) }), _jsx(TextInput, { id: 'cluster-migration-source-kms-key', labelText: t.sourceKmsKeyLabel, helperText: bucket === '' ? t.sourceKmsKeyNeedsBucket : undefined, value: kmsKeyArn, invalid: !kmsValid, invalidText: t.sourceKmsKeyInvalid, disabled: disabled || bucket === '', onChange: (event) => setKmsKeyArn(event.target.value.trim()) }), _jsxs(Stack, { gap: 3, children: [_jsx("h4", { children: t.policyTitle }), _jsx("p", { children: t.policyText }), !access?.bucket && (_jsx("div", { "data-testid": 'cluster-migration-policy-preparing', children: _jsx(C4InlineNotification, { kind: 'info', title: '', subtitle: t.policyPreparing, hideCloseButton: true }) })), policy && policy.Statement.length > 0 && (_jsx("div", { "data-testid": 'cluster-migration-policy', children: _jsx(DsCodeBlock, { children: JSON.stringify(policy, undefined, 2) }) }))] }), _jsx("div", { children: _jsx(Button, { disabled: disabled || !bucketValid || !kmsValid, onClick: () => onTransferFinished({
|
|
41
|
+
bucket: bucket || undefined,
|
|
42
|
+
kmsKeyArn: sourceKmsKeyArn || undefined,
|
|
43
|
+
}), children: t.transferFinishedButton }) })] }));
|
|
44
|
+
}
|
|
45
|
+
function BackupChoicePanel({ migration, disabled, onChooseBackup, onReopenTransfer, translations: t, }) {
|
|
46
|
+
// A new attempt often uses the same backup, thus the last choice is the
|
|
47
|
+
// start value.
|
|
48
|
+
const last = migration.spec.backup;
|
|
49
|
+
const [backupId, setBackupId] = useState(last?.backupId ?? '');
|
|
50
|
+
const [partitions, setPartitions] = useState(last ? String(last.partitionsCount) : '');
|
|
18
51
|
const idValid = isValidBackupId(backupId);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
setBackupId(event.target.value.trim());
|
|
23
|
-
} }), _jsx(Checkbox, { id: 'cluster-migration-transfer-done', labelText: t.transferDoneLabel, checked: transferDone, disabled: busy, onChange: (event) => setTransferDone(event.target.checked) }), _jsx(C4InlineNotification, { kind: 'warning', title: '', subtitle: t.restoreWarning, hideCloseButton: true }), error && (_jsx(C4InlineNotification, { kind: 'error', title: '', subtitle: error, hideCloseButton: true })), _jsx("div", { children: _jsx(Button, { disabled: busy || !canConfirm || !idValid || !transferDone, onClick: () => onConfirm(backupId), children: t.confirmButton }) })] }));
|
|
52
|
+
const partitionsValid = isValidPartitionsCount(partitions);
|
|
53
|
+
const [backupCopied, setBackupCopied] = useState(false);
|
|
54
|
+
return (_jsxs(_Fragment, { children: [_jsx(TextInput, { id: 'cluster-migration-backup-id', labelText: t.backupIdLabel, value: backupId, invalid: backupId !== '' && !idValid, invalidText: t.backupIdInvalid, disabled: disabled, onChange: (event) => setBackupId(event.target.value.trim()) }), _jsx(TextInput, { id: 'cluster-migration-partitions', labelText: t.partitionsLabel, helperText: t.partitionsHelper, value: partitions, invalid: partitions !== '' && !partitionsValid, invalidText: t.partitionsInvalid, disabled: disabled, onChange: (event) => setPartitions(event.target.value.trim()) }), _jsx(C4InlineNotification, { kind: 'warning', title: '', subtitle: t.restoreWarning, hideCloseButton: true }), _jsx(Checkbox, { id: 'cluster-migration-backup-copied', labelText: t.backupCopiedLabel, checked: backupCopied, disabled: disabled, onChange: (event) => setBackupCopied(event.target.checked) }), _jsxs(Stack, { orientation: 'horizontal', gap: 3, children: [_jsx(Button, { disabled: disabled || !idValid || !partitionsValid || !backupCopied, onClick: () => onChooseBackup({ backupId, partitionsCount: Number(partitions) }), children: t.chooseBackupButton }), onReopenTransfer && (_jsx(Button, { kind: 'secondary', disabled: disabled, onClick: onReopenTransfer, children: t.reopenTransferButton }))] })] }));
|
|
24
55
|
}
|
|
@@ -1,23 +1,58 @@
|
|
|
1
|
+
import type { MigrationPhase, MigrationReason, MigrationReasonParams, MigrationSourceInput, MigrationView } from '../../utils/migration-view.js';
|
|
1
2
|
export interface C4ClusterMigrationTranslations {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
title: Record<MigrationPhase, string>;
|
|
4
|
+
/**
|
|
5
|
+
* The text of a reason with its values. Without a reason, the general text
|
|
6
|
+
* of the phase.
|
|
7
|
+
*/
|
|
8
|
+
reasonText: (phase: MigrationPhase, reason: MigrationReason | undefined, params: MigrationReasonParams) => string;
|
|
9
|
+
principalLabel: string;
|
|
10
|
+
sourceBucketLabel: string;
|
|
11
|
+
sourceBucketHelper: string;
|
|
12
|
+
sourceBucketInvalid: string;
|
|
13
|
+
sourceKmsKeyLabel: string;
|
|
14
|
+
/** Shown while the KMS field is disabled, because the bucket is empty. */
|
|
15
|
+
sourceKmsKeyNeedsBucket: string;
|
|
16
|
+
sourceKmsKeyInvalid: string;
|
|
17
|
+
policyTitle: string;
|
|
18
|
+
policyText: string;
|
|
19
|
+
/** Shown while the backup storage of the cluster does not exist yet. */
|
|
20
|
+
policyPreparing: string;
|
|
21
|
+
transferFinishedButton: string;
|
|
5
22
|
backupIdLabel: string;
|
|
6
23
|
backupIdInvalid: string;
|
|
7
|
-
|
|
24
|
+
partitionsLabel: string;
|
|
25
|
+
partitionsHelper: string;
|
|
26
|
+
partitionsInvalid: string;
|
|
8
27
|
restoreWarning: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
28
|
+
/** The required check before a restore: a restore replaces all data. */
|
|
29
|
+
backupCopiedLabel: string;
|
|
30
|
+
chooseBackupButton: string;
|
|
31
|
+
reopenTransferButton: string;
|
|
32
|
+
progressText: string;
|
|
33
|
+
deleteButton: string;
|
|
34
|
+
}
|
|
35
|
+
export interface C4ClusterMigrationBackupChoice {
|
|
36
|
+
/** A string, because a number loses digits above 2^53. */
|
|
37
|
+
backupId: string;
|
|
38
|
+
partitionsCount: number;
|
|
12
39
|
}
|
|
13
40
|
export interface C4ClusterMigrationProps {
|
|
14
|
-
|
|
15
|
-
roleArn?: string;
|
|
41
|
+
migration: MigrationView;
|
|
16
42
|
busy?: boolean;
|
|
17
43
|
/** False for a member without the right to update the cluster. */
|
|
18
|
-
|
|
44
|
+
canEdit?: boolean;
|
|
19
45
|
error?: string;
|
|
20
|
-
/**
|
|
21
|
-
|
|
46
|
+
/** Transferring: the customer finished the copy. */
|
|
47
|
+
onTransferFinished: (source: MigrationSourceInput) => void;
|
|
48
|
+
/** AwaitingBackup: the customer must copy more. */
|
|
49
|
+
onReopenTransfer: () => void;
|
|
50
|
+
/** AwaitingBackup and RestoreFailed: a new attempt with this backup. */
|
|
51
|
+
onChooseBackup: (choice: C4ClusterMigrationBackupChoice) => void;
|
|
52
|
+
/**
|
|
53
|
+
* VerificationFailed: the next step is a new migration cluster. Not set for
|
|
54
|
+
* a member without the right to delete the cluster.
|
|
55
|
+
*/
|
|
56
|
+
onDelete?: () => void;
|
|
22
57
|
translations: C4ClusterMigrationTranslations;
|
|
23
58
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type TranslateFn } from '../../utils/safe-translate.js';
|
|
2
2
|
import type { C4ClusterMigrationTranslations } from './c4-cluster-migration.types.js';
|
|
3
|
-
|
|
4
|
-
export declare const buildMigrationTranslations: (t: T) => C4ClusterMigrationTranslations;
|
|
5
|
-
export {};
|
|
3
|
+
export declare const buildMigrationTranslations: (t: TranslateFn | undefined) => C4ClusterMigrationTranslations;
|
|
@@ -3,19 +3,94 @@
|
|
|
3
3
|
* under one or more contributor license agreements. Licensed under a commercial license.
|
|
4
4
|
* You may not use this file except in compliance with the commercial license.
|
|
5
5
|
*/
|
|
6
|
+
import { MIGRATION_PHASES, } from '../../utils/migration-view.js';
|
|
6
7
|
import { safeTranslate } from '../../utils/safe-translate.js';
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// the
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
// The English text lives in `i18n/en/pages/clusterdetails.json`. The defaults
|
|
9
|
+
// here keep a host without the c4 catalog readable. The reason texts follow
|
|
10
|
+
// the messages of the operator contract.
|
|
11
|
+
const TITLE = {
|
|
12
|
+
AwaitingPrincipal: 'Preparing the migration',
|
|
13
|
+
Transferring: 'Transfer your backup',
|
|
14
|
+
AwaitingBackup: 'Choose the backup',
|
|
15
|
+
Verifying: 'Checking the backup',
|
|
16
|
+
Restoring: 'Restoring the backup',
|
|
17
|
+
Completed: 'Migration complete',
|
|
18
|
+
VerificationFailed: "The backup can't be used",
|
|
19
|
+
RestoreFailed: 'Restore failed',
|
|
20
|
+
};
|
|
21
|
+
/** The text of a phase that has no reason. */
|
|
22
|
+
const PHASE = {
|
|
23
|
+
AwaitingPrincipal: 'Giving your IAM role access to the backup storage of this cluster.',
|
|
24
|
+
Transferring: 'Your IAM role can copy backups into the backup storage of this cluster. Confirm when the copy is finished.',
|
|
25
|
+
AwaitingBackup: 'Choose the backup to restore.',
|
|
26
|
+
Verifying: 'Checking that the backup is complete and works with this cluster.',
|
|
27
|
+
Restoring: 'Restoring the backup.',
|
|
28
|
+
Completed: 'The migration is complete.',
|
|
29
|
+
VerificationFailed: "The backup didn't pass the checks. Nothing in this cluster changed. Delete this cluster and start a new migration.",
|
|
30
|
+
RestoreFailed: 'The restore failed. Choose a backup to try again. The next restore replaces all data.',
|
|
31
|
+
};
|
|
32
|
+
const REASON = {
|
|
33
|
+
WaitingForPrincipal: 'Enter the IAM role that you created to copy your backups.',
|
|
34
|
+
GrantingAccess: 'Giving your IAM role access to the backup storage of this cluster.',
|
|
35
|
+
TransferOpen: 'Your IAM role can copy backups into the backup storage of this cluster. Confirm when the copy is finished.',
|
|
36
|
+
RemovingAccess: 'Removing the access of your IAM role to the backup storage of this cluster.',
|
|
37
|
+
WaitingForBackupChoice: 'Choose the backup to restore.',
|
|
38
|
+
BackupNotFound: "Backup {{backupId}} isn't in the backup storage of this cluster. Choose another backup or reopen the transfer.",
|
|
39
|
+
PartitionCountMismatch: 'Backup {{backupId}} has {{backupPartitions}} partitions, not {{chosenPartitions}}. Check the partition count and choose again.',
|
|
40
|
+
VerifyingBackup: 'Checking that backup {{backupId}} is complete and works with this cluster.',
|
|
41
|
+
RestoringBackup: 'Restoring backup {{backupId}}.',
|
|
42
|
+
MigrationCompleted: 'The migration is complete.',
|
|
43
|
+
BackupIncomplete: 'Backup {{backupId}} is incomplete. Copy it again completely into a new migration cluster.',
|
|
44
|
+
SnapshotsMissing: 'Some data of backup {{backupId}} is missing. Copy the whole backup, including all Elasticsearch snapshots, into a new migration cluster.',
|
|
45
|
+
BackupUnreadable: 'Backup {{backupId}} was written with an encryption key other than the key of this cluster. Copy it into a new migration cluster without encryption options.',
|
|
46
|
+
ElasticsearchVersionIncompatible: 'The backup was taken with Elasticsearch {{backupVersion}}, which is newer than {{clusterVersion}} of this cluster. Create a new migration cluster with Elasticsearch {{backupVersion}} or later.',
|
|
47
|
+
CamundaVersionIncompatible: 'The backup was taken with Camunda {{backupVersion}}, which is newer than {{clusterVersion}} of this cluster. Create a new migration cluster with Camunda {{backupVersion}} or later.',
|
|
48
|
+
PartitionCountIncompatible: 'The backup has {{backupPartitions}} partitions, but this cluster has {{clusterPartitions}}. Create a new migration cluster with {{backupPartitions}} partitions.',
|
|
49
|
+
InsufficientDiskSize: 'Backup {{backupId}} needs more disk than this cluster has. Create a new migration cluster with a larger plan.',
|
|
50
|
+
RestoreFailedBeforeDataDeletion: 'The restore of backup {{backupId}} failed before it changed data in this cluster. Choose a backup to try again.',
|
|
51
|
+
RestoreFailedAfterDataDeletion: 'The restore of backup {{backupId}} failed after the data of this cluster was replaced. The cluster might be partly restored. Choose a backup to try again. The next restore replaces all data.',
|
|
52
|
+
};
|
|
53
|
+
const PLACEHOLDER = /{{(\w+)}}/g;
|
|
54
|
+
const placeholders = (template) => [...template.matchAll(PLACEHOLDER)].map((match) => match[1]);
|
|
55
|
+
const interpolate = (template, params) => template.replace(PLACEHOLDER, (_, name) => String(params[name] ?? ''));
|
|
56
|
+
export const buildMigrationTranslations = (t) => {
|
|
57
|
+
const text = (key, fallback) => safeTranslate(t, `clusterdetails:migration.${key}`, fallback);
|
|
58
|
+
return {
|
|
59
|
+
title: Object.fromEntries(MIGRATION_PHASES.map((phase) => [
|
|
60
|
+
phase,
|
|
61
|
+
text(`title.${phase}`, TITLE[phase]),
|
|
62
|
+
])),
|
|
63
|
+
reasonText: (phase, reason, params) => {
|
|
64
|
+
const template = reason ? REASON[reason] : undefined;
|
|
65
|
+
// A reason without its values would show a gap. The text of the phase
|
|
66
|
+
// is better.
|
|
67
|
+
if (!template ||
|
|
68
|
+
placeholders(template).some((name) => params[name] === undefined)) {
|
|
69
|
+
return text(`phase.${phase}`, PHASE[phase]);
|
|
70
|
+
}
|
|
71
|
+
return safeTranslate(t, `clusterdetails:migration.reason.${reason}`, interpolate(template, params), { ...params });
|
|
72
|
+
},
|
|
73
|
+
principalLabel: text('principalLabel', 'IAM role:'),
|
|
74
|
+
sourceBucketLabel: text('sourceBucketLabel', 'Self-Managed backup bucket (optional)'),
|
|
75
|
+
sourceBucketHelper: text('sourceBucketHelper', 'Enter it to add the read access to this bucket to the policy.'),
|
|
76
|
+
sourceBucketInvalid: text('sourceBucketInvalid', 'Enter a valid S3 bucket name, or leave it empty.'),
|
|
77
|
+
sourceKmsKeyLabel: text('sourceKmsKeyLabel', 'KMS key ARN of the bucket (optional)'),
|
|
78
|
+
sourceKmsKeyNeedsBucket: text('sourceKmsKeyNeedsBucket', 'Enter the bucket first.'),
|
|
79
|
+
sourceKmsKeyInvalid: text('sourceKmsKeyInvalid', 'Enter a valid KMS key ARN, or leave it empty.'),
|
|
80
|
+
policyTitle: text('policyTitle', 'IAM policy'),
|
|
81
|
+
policyText: text('policyText', 'Attach this policy to your IAM role. It lets the role read your backup and write it into the backup storage of this cluster.'),
|
|
82
|
+
policyPreparing: text('policyPreparing', 'Camunda is preparing the backup storage of this cluster. The policy gets its statements for it when the storage is ready.'),
|
|
83
|
+
transferFinishedButton: text('transferFinishedButton', 'Transfer finished'),
|
|
84
|
+
backupIdLabel: text('backupIdLabel', 'Backup ID'),
|
|
85
|
+
backupIdInvalid: text('backupIdInvalid', 'Enter a whole number from 1 to 9223372036854775807.'),
|
|
86
|
+
partitionsLabel: text('partitionsLabel', 'Partitions'),
|
|
87
|
+
partitionsHelper: text('partitionsHelper', 'The partition count of the backup. Enter 0 for a backup with Elasticsearch data only.'),
|
|
88
|
+
partitionsInvalid: text('partitionsInvalid', 'Enter a whole number from 0 to 2147483647.'),
|
|
89
|
+
restoreWarning: text('restoreWarning', 'The restore replaces all data in this cluster.'),
|
|
90
|
+
backupCopiedLabel: text('backupCopiedLabel', 'I copied the backup'),
|
|
91
|
+
chooseBackupButton: text('chooseBackupButton', 'Restore backup'),
|
|
92
|
+
reopenTransferButton: text('reopenTransferButton', 'Reopen transfer'),
|
|
93
|
+
progressText: text('progressText', 'This cluster has no actions until the migration ends. To cancel the migration, delete the cluster.'),
|
|
94
|
+
deleteButton: text('deleteButton', 'Delete cluster'),
|
|
95
|
+
};
|
|
96
|
+
};
|
|
@@ -779,19 +779,68 @@
|
|
|
779
779
|
}
|
|
780
780
|
},
|
|
781
781
|
"migration": {
|
|
782
|
-
"
|
|
783
|
-
"
|
|
784
|
-
"
|
|
785
|
-
"
|
|
786
|
-
"
|
|
787
|
-
"
|
|
788
|
-
"
|
|
789
|
-
"
|
|
790
|
-
"
|
|
791
|
-
},
|
|
792
|
-
"
|
|
793
|
-
"
|
|
794
|
-
"
|
|
795
|
-
|
|
782
|
+
"title": {
|
|
783
|
+
"AwaitingPrincipal": "Preparing the migration",
|
|
784
|
+
"Transferring": "Transfer your backup",
|
|
785
|
+
"AwaitingBackup": "Choose the backup",
|
|
786
|
+
"Verifying": "Checking the backup",
|
|
787
|
+
"Restoring": "Restoring the backup",
|
|
788
|
+
"Completed": "Migration complete",
|
|
789
|
+
"VerificationFailed": "The backup can't be used",
|
|
790
|
+
"RestoreFailed": "Restore failed"
|
|
791
|
+
},
|
|
792
|
+
"phase": {
|
|
793
|
+
"AwaitingPrincipal": "Giving your IAM role access to the backup storage of this cluster.",
|
|
794
|
+
"Transferring": "Your IAM role can copy backups into the backup storage of this cluster. Confirm when the copy is finished.",
|
|
795
|
+
"AwaitingBackup": "Choose the backup to restore.",
|
|
796
|
+
"Verifying": "Checking that the backup is complete and works with this cluster.",
|
|
797
|
+
"Restoring": "Restoring the backup.",
|
|
798
|
+
"Completed": "The migration is complete.",
|
|
799
|
+
"VerificationFailed": "The backup didn't pass the checks. Nothing in this cluster changed. Delete this cluster and start a new migration.",
|
|
800
|
+
"RestoreFailed": "The restore failed. Choose a backup to try again. The next restore replaces all data."
|
|
801
|
+
},
|
|
802
|
+
"reason": {
|
|
803
|
+
"WaitingForPrincipal": "Enter the IAM role that you created to copy your backups.",
|
|
804
|
+
"GrantingAccess": "Giving your IAM role access to the backup storage of this cluster.",
|
|
805
|
+
"TransferOpen": "Your IAM role can copy backups into the backup storage of this cluster. Confirm when the copy is finished.",
|
|
806
|
+
"RemovingAccess": "Removing the access of your IAM role to the backup storage of this cluster.",
|
|
807
|
+
"WaitingForBackupChoice": "Choose the backup to restore.",
|
|
808
|
+
"BackupNotFound": "Backup {{backupId}} isn't in the backup storage of this cluster. Choose another backup or reopen the transfer.",
|
|
809
|
+
"PartitionCountMismatch": "Backup {{backupId}} has {{backupPartitions}} partitions, not {{chosenPartitions}}. Check the partition count and choose again.",
|
|
810
|
+
"VerifyingBackup": "Checking that backup {{backupId}} is complete and works with this cluster.",
|
|
811
|
+
"RestoringBackup": "Restoring backup {{backupId}}.",
|
|
812
|
+
"MigrationCompleted": "The migration is complete.",
|
|
813
|
+
"BackupIncomplete": "Backup {{backupId}} is incomplete. Copy it again completely into a new migration cluster.",
|
|
814
|
+
"SnapshotsMissing": "Some data of backup {{backupId}} is missing. Copy the whole backup, including all Elasticsearch snapshots, into a new migration cluster.",
|
|
815
|
+
"BackupUnreadable": "Backup {{backupId}} was written with an encryption key other than the key of this cluster. Copy it into a new migration cluster without encryption options.",
|
|
816
|
+
"ElasticsearchVersionIncompatible": "The backup was taken with Elasticsearch {{backupVersion}}, which is newer than {{clusterVersion}} of this cluster. Create a new migration cluster with Elasticsearch {{backupVersion}} or later.",
|
|
817
|
+
"CamundaVersionIncompatible": "The backup was taken with Camunda {{backupVersion}}, which is newer than {{clusterVersion}} of this cluster. Create a new migration cluster with Camunda {{backupVersion}} or later.",
|
|
818
|
+
"PartitionCountIncompatible": "The backup has {{backupPartitions}} partitions, but this cluster has {{clusterPartitions}}. Create a new migration cluster with {{backupPartitions}} partitions.",
|
|
819
|
+
"InsufficientDiskSize": "Backup {{backupId}} needs more disk than this cluster has. Create a new migration cluster with a larger plan.",
|
|
820
|
+
"RestoreFailedBeforeDataDeletion": "The restore of backup {{backupId}} failed before it changed data in this cluster. Choose a backup to try again.",
|
|
821
|
+
"RestoreFailedAfterDataDeletion": "The restore of backup {{backupId}} failed after the data of this cluster was replaced. The cluster might be partly restored. Choose a backup to try again. The next restore replaces all data."
|
|
822
|
+
},
|
|
823
|
+
"principalLabel": "IAM role:",
|
|
824
|
+
"sourceBucketLabel": "Self-Managed backup bucket (optional)",
|
|
825
|
+
"sourceBucketHelper": "Enter it to add the read access to this bucket to the policy.",
|
|
826
|
+
"sourceBucketInvalid": "Enter a valid S3 bucket name, or leave it empty.",
|
|
827
|
+
"sourceKmsKeyLabel": "KMS key ARN of the bucket (optional)",
|
|
828
|
+
"sourceKmsKeyNeedsBucket": "Enter the bucket first.",
|
|
829
|
+
"sourceKmsKeyInvalid": "Enter a valid KMS key ARN, or leave it empty.",
|
|
830
|
+
"policyTitle": "IAM policy",
|
|
831
|
+
"policyText": "Attach this policy to your IAM role. It lets the role read your backup and write it into the backup storage of this cluster.",
|
|
832
|
+
"policyPreparing": "Camunda is preparing the backup storage of this cluster. The policy gets its statements for it when the storage is ready.",
|
|
833
|
+
"transferFinishedButton": "Transfer finished",
|
|
834
|
+
"backupIdLabel": "Backup ID",
|
|
835
|
+
"backupIdInvalid": "Enter a whole number from 1 to 9223372036854775807.",
|
|
836
|
+
"partitionsLabel": "Partitions",
|
|
837
|
+
"partitionsHelper": "The partition count of the backup. Enter 0 for a backup with Elasticsearch data only.",
|
|
838
|
+
"partitionsInvalid": "Enter a whole number from 0 to 2147483647.",
|
|
839
|
+
"restoreWarning": "The restore replaces all data in this cluster.",
|
|
840
|
+
"backupCopiedLabel": "I copied the backup",
|
|
841
|
+
"chooseBackupButton": "Restore backup",
|
|
842
|
+
"reopenTransferButton": "Reopen transfer",
|
|
843
|
+
"progressText": "This cluster has no actions until the migration ends. To cancel the migration, delete the cluster.",
|
|
844
|
+
"deleteButton": "Delete cluster"
|
|
796
845
|
}
|
|
797
846
|
}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export { C4ClusterList } from './components/c4-cluster-list/c4-cluster-list.js';
|
|
|
59
59
|
export type { C4ClusterListProps, ClusterListItem, ClusterListNotification, ClusterListPermissions, ClusterListUrls, } from './components/c4-cluster-list/c4-cluster-list.types.js';
|
|
60
60
|
export { type ClusterExpiryRemaining, type ClusterExpiryTag, type ClusterExpiryTagCopy, DEFAULT_CLUSTER_EXPIRY_TAG_COPY, getClusterExpiryRemaining, getClusterExpiryTag, } from './components/c4-cluster-list/cluster-expiry-tag.js';
|
|
61
61
|
export { C4ClusterMigration } from './components/c4-cluster-migration/c4-cluster-migration.js';
|
|
62
|
-
export type { C4ClusterMigrationProps, C4ClusterMigrationTranslations, } from './components/c4-cluster-migration/c4-cluster-migration.types.js';
|
|
62
|
+
export type { C4ClusterMigrationBackupChoice, C4ClusterMigrationProps, C4ClusterMigrationTranslations, } from './components/c4-cluster-migration/c4-cluster-migration.types.js';
|
|
63
63
|
export type { ApplicationsProps, ApplicationTileProps, ClusterStatus, } from './components/c4-cluster-overview/applications.js';
|
|
64
64
|
export { ClusterStatusElement, normalizeClusterStatus, } from './components/c4-cluster-overview/applications.js';
|
|
65
65
|
export { C4ClusterOverview, C4IconAndTextElement, getClusterLoadConfig, getDsClusterLoadPresentation, } from './components/c4-cluster-overview/c4-cluster-overview.js';
|
|
@@ -215,6 +215,7 @@ export { openC4InviteUserToOrganizationModal, setC4InviteUserToOrganizationModal
|
|
|
215
215
|
export { openC4RenameOrganizationModal, setC4RenameOrganizationModalHandle, } from './modals/c4-rename-organization-modal-handle.js';
|
|
216
216
|
export type { AccountsPermissions, AddC4ConsoleNotificationOptions, C4BreadcrumbCrumb, C4BreadcrumbDropdownItem, C4ClusterNavAppEntry, C4ClusterNavEntry, C4ConsoleAuthzFeatures, C4ConsoleAuthzState, C4ConsoleDataState, C4ConsoleEventsProviderProps, C4ConsoleNotification, C4ConsoleNotificationAction, C4ConsoleNotificationKind, C4ConsoleNotificationsState, C4ConsoleRuntimeConfig, C4ConsoleVisibilities, C4ResolvedTheme, C4ThemePreference, C4UserNotificationsProviderProps, C4UserNotificationsState, C4UserThemeState, CacheState, CamundaWebApp, ConsoleAuth, ConsoleBackendUrls, ConsoleClickwrapConfig, ConsoleClusterDto, ConsolePermissions, ConsolePublicUrls, ConsoleStage, ConsoleTelemetry, ConsoleUser, ExternalClusterDto, ExternalOrganizationDto, NotificationDto, OrganizationPermissions, OrganizationRole, OrgCache, SseEntity, UpgradableGenerationsDto, UseC4ClusterNavEntriesOptions, UseC4WebappBreadcrumbDataOptions, } from './runtime/index.js';
|
|
217
217
|
export { addC4ConsoleNotification, buildClusterSsoCallbackUrl, buildClusterSwaggerUrl, buildModelerOrgUrl, C4ConsoleDataProvider, C4ConsoleEventsProvider, C4ConsoleNotificationsProvider, C4ConsoleRuntimeProvider, C4UserNotificationsProvider, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, removeC4ConsoleNotificationById, resolveAdminAppName, setC4ConsoleNotificationsHandle, useC4ClusterNavEntries, useC4ConsoleAuthz, useC4ConsoleData, useC4ConsoleEventsState, useC4ConsoleNotifications, useC4ConsoleRuntime, useC4ConsoleStage, useC4FeatureFlag, useC4TwoPhaseUpgradeMockup, useC4UserNotifications, useC4UserTheme, useC4WebappBreadcrumbData, } from './runtime/index.js';
|
|
218
|
+
export type { MigrationAccess, MigrationAccessStatement, MigrationBackupChoice, MigrationDetectedBackup, MigrationPhase, MigrationReason, MigrationReasonParams, MigrationSourceAccess, MigrationSourceInput, MigrationSourceKind, MigrationSpec, MigrationView, } from './utils/migration-view.js';
|
|
218
219
|
export type { TranslateFn } from './utils/safe-translate.js';
|
|
219
220
|
export { ENVIRONMENT_KEY_SUFFIX, safeTranslate, scopedTranslate, } from './utils/safe-translate.js';
|
|
220
221
|
export type { C4WidgetScope } from './widgets/c4-widget-scope.types.js';
|
|
@@ -7,9 +7,13 @@ import { type TwoPhaseUpgradeMode, type TwoPhaseUpgradeStateDto } from '@camunda
|
|
|
7
7
|
* `refreshKey` changes when the cluster status or generation changes, and the
|
|
8
8
|
* hook then reads the state again. An answer for another cluster or an older
|
|
9
9
|
* request never replaces the current state.
|
|
10
|
+
*
|
|
11
|
+
* The caller gives `orgId`: a host such as console-frontend sets no `orgId`
|
|
12
|
+
* in the runtime config.
|
|
10
13
|
*/
|
|
11
|
-
export declare function useC4TwoPhaseUpgradeMockup({ enabled, clusterId, refreshKey, }: {
|
|
14
|
+
export declare function useC4TwoPhaseUpgradeMockup({ enabled, orgId, clusterId, refreshKey, }: {
|
|
12
15
|
enabled: boolean;
|
|
16
|
+
orgId: string;
|
|
13
17
|
clusterId: string;
|
|
14
18
|
refreshKey: string;
|
|
15
19
|
}): {
|
|
@@ -22,10 +22,12 @@ const AUTO_PENDING_POLL_MS = 5000;
|
|
|
22
22
|
* `refreshKey` changes when the cluster status or generation changes, and the
|
|
23
23
|
* hook then reads the state again. An answer for another cluster or an older
|
|
24
24
|
* request never replaces the current state.
|
|
25
|
+
*
|
|
26
|
+
* The caller gives `orgId`: a host such as console-frontend sets no `orgId`
|
|
27
|
+
* in the runtime config.
|
|
25
28
|
*/
|
|
26
|
-
export function useC4TwoPhaseUpgradeMockup({ enabled, clusterId, refreshKey, }) {
|
|
29
|
+
export function useC4TwoPhaseUpgradeMockup({ enabled, orgId, clusterId, refreshKey, }) {
|
|
27
30
|
const runtime = useC4ConsoleRuntime();
|
|
28
|
-
const { orgId } = runtime;
|
|
29
31
|
const [state, setState] = useState();
|
|
30
32
|
// Counts every request. An answer counts only if it is still the latest.
|
|
31
33
|
const latest = useRef(0);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MigrationAccess, MigrationSourceInput } from './migration-view.js';
|
|
2
|
+
export declare const isValidS3BucketName: (value: string) => boolean;
|
|
3
|
+
export declare const isValidKmsKeyArn: (value: string) => boolean;
|
|
4
|
+
export interface AwsPolicyStatement {
|
|
5
|
+
Effect: 'Allow';
|
|
6
|
+
Action: string[];
|
|
7
|
+
Resource: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AwsPolicyDocument {
|
|
10
|
+
Version: '2012-10-17';
|
|
11
|
+
Statement: AwsPolicyStatement[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The policy of the customer's principal: the target statements of `access`,
|
|
15
|
+
* and the source statements when the source bucket is valid. The `Key`
|
|
16
|
+
* statement is left out when the source bucket uses no KMS key.
|
|
17
|
+
*/
|
|
18
|
+
export declare const buildAwsMigrationPolicy: ({ access, source, principal, }: {
|
|
19
|
+
access: MigrationAccess;
|
|
20
|
+
source: MigrationSourceInput;
|
|
21
|
+
principal: string;
|
|
22
|
+
}) => AwsPolicyDocument;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
|
|
3
|
+
* under one or more contributor license agreements. Licensed under a commercial license.
|
|
4
|
+
* You may not use this file except in compliance with the commercial license.
|
|
5
|
+
*/
|
|
6
|
+
// The contract publishes the actions. Console adds the resources of the
|
|
7
|
+
// source side that the customer enters, and renders one IAM policy for the
|
|
8
|
+
// customer's principal.
|
|
9
|
+
const S3_BUCKET_NAME_PATTERN = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;
|
|
10
|
+
// AWS forbids two periods, a period next to a hyphen, an IP address form, and
|
|
11
|
+
// the prefixes and suffixes that it keeps for its own use.
|
|
12
|
+
const S3_BUCKET_NAME_FORBIDDEN = /\.\.|\.-|-\.|^\d+\.\d+\.\d+\.\d+$|^(xn--|sthree-|amzn-s3-demo-)|(-s3alias|--ol-s3|\.mrap|--x-s3|--table-s3)$/;
|
|
13
|
+
const KMS_KEY_ARN_PATTERN = /^arn:(aws|aws-cn|aws-us-gov):kms:[a-z0-9-]+:[0-9]{12}:key\/[A-Za-z0-9-]{1,128}$/;
|
|
14
|
+
export const isValidS3BucketName = (value) => S3_BUCKET_NAME_PATTERN.test(value) && !S3_BUCKET_NAME_FORBIDDEN.test(value);
|
|
15
|
+
export const isValidKmsKeyArn = (value) => KMS_KEY_ARN_PATTERN.test(value);
|
|
16
|
+
/** The AWS partition of an ARN, for example `aws` or `aws-cn`. */
|
|
17
|
+
const partitionOf = (arn) => arn.split(':')[1] || 'aws';
|
|
18
|
+
const sourceResource = (kind, bucketArn, kmsKeyArn) => {
|
|
19
|
+
if (kind === 'Bucket')
|
|
20
|
+
return bucketArn;
|
|
21
|
+
if (kind === 'Objects')
|
|
22
|
+
return `${bucketArn}/*`;
|
|
23
|
+
return kmsKeyArn;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The policy of the customer's principal: the target statements of `access`,
|
|
27
|
+
* and the source statements when the source bucket is valid. The `Key`
|
|
28
|
+
* statement is left out when the source bucket uses no KMS key.
|
|
29
|
+
*/
|
|
30
|
+
export const buildAwsMigrationPolicy = ({ access, source, principal, }) => {
|
|
31
|
+
const statements = access.statements.map((statement) => ({
|
|
32
|
+
Effect: 'Allow',
|
|
33
|
+
Action: statement.actions,
|
|
34
|
+
Resource: statement.resource,
|
|
35
|
+
}));
|
|
36
|
+
const bucket = source.bucket ?? '';
|
|
37
|
+
if (isValidS3BucketName(bucket)) {
|
|
38
|
+
const bucketArn = `arn:${partitionOf(principal)}:s3:::${bucket}`;
|
|
39
|
+
const kmsKeyArn = source.kmsKeyArn && isValidKmsKeyArn(source.kmsKeyArn)
|
|
40
|
+
? source.kmsKeyArn
|
|
41
|
+
: undefined;
|
|
42
|
+
for (const entry of access.source) {
|
|
43
|
+
const resource = sourceResource(entry.kind, bucketArn, kmsKeyArn);
|
|
44
|
+
if (resource) {
|
|
45
|
+
statements.push({
|
|
46
|
+
Effect: 'Allow',
|
|
47
|
+
Action: entry.actions,
|
|
48
|
+
Resource: resource,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return { Version: '2012-10-17', Statement: statements };
|
|
54
|
+
};
|