-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[SR] Snapshot and Restore UI #39193
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
[SR] Snapshot and Restore UI #39193
Changes from 39 commits
6ed1c54
de3c2c2
6dda580
a1d8c8d
21f8e5d
098cf76
259cfbe
bb48ae0
46be0da
67d5476
e0e82a8
10b380b
3a452ef
d44ec39
53fdeb8
ef57466
be1172d
7ac5a52
df0dd7c
395772e
3f17e1e
64f87ab
dd2797d
4b37d00
731c4d6
8f0fbe5
8563714
45c0548
fc8bc50
a6f0a13
c4fbf4b
3b11591
18a3062
8f1a7ab
cc55ad1
772fd8f
7263352
94c5130
469fbd2
a701055
950f0ff
ed52296
59785b6
a6bebbd
eb3f03d
a223042
b437a19
5bf2e94
7b7a1f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
| import { serializeRestoreSettings } from './restore_serialization'; | ||
|
|
||
| describe('restore_serialization', () => { | ||
| describe('restore_serialization()', () => { | ||
| it('should serialize restore settings', () => { | ||
| expect(serializeRestoreSettings({})).toEqual({}); | ||
| expect( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assertion seems like a subset of the next assertion. Is it testing something different? If so, maybe it could use its own |
||
| serializeRestoreSettings({ | ||
| indices: ['foo', 'bar'], | ||
| ignoreIndexSettings: ['setting1'], | ||
| partial: true, | ||
| }) | ||
| ).toEqual({ | ||
| indices: ['foo', 'bar'], | ||
| ignore_index_settings: ['setting1'], | ||
| partial: true, | ||
| }); | ||
| expect( | ||
| serializeRestoreSettings({ | ||
| indices: ['foo', 'bar'], | ||
| renamePattern: 'capture_pattern', | ||
| renameReplacement: 'replacement_pattern', | ||
| includeGlobalState: true, | ||
| partial: true, | ||
| indexSettings: '{"modified_setting":123}', | ||
| ignoreIndexSettings: ['setting1'], | ||
| }) | ||
| ).toEqual({ | ||
| indices: ['foo', 'bar'], | ||
| rename_pattern: 'capture_pattern', | ||
| rename_replacement: 'replacement_pattern', | ||
| include_global_state: true, | ||
| partial: true, | ||
| index_settings: { modified_setting: 123 }, | ||
| ignore_index_settings: ['setting1'], | ||
| }); | ||
| }); | ||
|
|
||
| it('should skip serialization of invalid json index settings', () => { | ||
| expect( | ||
| serializeRestoreSettings({ | ||
| indexSettings: '{"invalid_setting:123,}', | ||
| }) | ||
| ).toEqual({}); | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
| import { RestoreSettings, RestoreSettingsEs } from '../types'; | ||
|
|
||
| export function serializeRestoreSettings(restoreSettings: RestoreSettings): RestoreSettingsEs { | ||
| const { | ||
| indices, | ||
| renamePattern, | ||
| renameReplacement, | ||
| includeGlobalState, | ||
| partial, | ||
| indexSettings, | ||
| ignoreIndexSettings, | ||
| } = restoreSettings; | ||
|
|
||
| let parsedIndexSettings: RestoreSettingsEs['index_settings'] | undefined; | ||
| if (indexSettings) { | ||
| try { | ||
| parsedIndexSettings = JSON.parse(indexSettings); | ||
| } catch (e) { | ||
| // Silently swallow parsing errors | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would throwing the error hurt? If so, can we add a comment for the rationale behind silently swallowing the error? If not, can we throw it to be a bit more defensive and transparent? |
||
| } | ||
| } | ||
|
|
||
| const settings: RestoreSettingsEs = { | ||
| indices, | ||
| rename_pattern: renamePattern, | ||
| rename_replacement: renameReplacement, | ||
| include_global_state: includeGlobalState, | ||
| partial, | ||
| index_settings: parsedIndexSettings, | ||
| ignore_index_settings: ignoreIndexSettings, | ||
| }; | ||
|
|
||
| return Object.entries(settings).reduce((sts: RestoreSettingsEs, [key, value]) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can read this just fine, but maybe a comment along the lines of |
||
| if (value !== undefined) { | ||
| sts[key as keyof RestoreSettingsEs] = value; | ||
| } | ||
| return sts; | ||
| }, {}); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,5 @@ | |
|
|
||
| export * from './repository'; | ||
| export * from './snapshot'; | ||
| export * from './restore'; | ||
| export * from './recovery'; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| export interface SnapshotRecovery { | ||
| index: string; | ||
| latestActivityTimeInMillis: number; | ||
| shards: Array<Partial<SnapshotRecoveryShard>>; | ||
| isComplete: boolean; | ||
| } | ||
|
|
||
| export interface SnapshotRecoveryShard { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice types! I find these really informative (which is an unusual development in my relationship with types). 😄 |
||
| id: number; | ||
| primary: boolean; | ||
| stage: string; | ||
| snapshot: string; | ||
| repository: string; | ||
| version: string; | ||
|
|
||
| targetHost: string; | ||
| targetNode: string; | ||
|
|
||
| /** e.g. '2019-04-05T21:56:40.438Z' */ | ||
| startTime: string; | ||
| startTimeInMillis: number; | ||
| /** e.g. '2019-04-05T21:56:40.438Z' */ | ||
| stopTime: string; | ||
| stopTimeInMillis: number; | ||
| totalTime: string; | ||
| totalTimeInMillis: number; | ||
|
|
||
| bytesTotal: number; | ||
| bytesRecovered: number; | ||
| bytesPercent: string; | ||
|
|
||
| filesTotal: number; | ||
| filesRecovered: number; | ||
| filesPercent: string; | ||
|
|
||
| translogTotal: number; | ||
| translogRecovered: number; | ||
| translogPercent: string; | ||
| } | ||
|
|
||
| export interface SnapshotRecoveryShardEs { | ||
| id: number; | ||
| type: string; | ||
| stage: string; | ||
| primary: boolean; | ||
| /** e.g. '2019-04-05T21:56:40.438Z' */ | ||
| start_time: string; | ||
| start_time_in_millis: number; | ||
| /** e.g. '2019-04-05T21:56:40.438Z' */ | ||
| stop_time: string; | ||
| stop_time_in_millis: number; | ||
| total_time: string; | ||
| total_time_in_millis: number; | ||
| source: { | ||
| repository: string; | ||
| snapshot: string; | ||
| version: string; | ||
| index: string; | ||
| restoreUUID: string; | ||
| }; | ||
| target: { | ||
| id: string; | ||
| host: string; | ||
| transport_address: string; | ||
| ip: string; | ||
| name: string; | ||
| }; | ||
| index: { | ||
| size: { | ||
| total: string; | ||
| total_in_bytes: number; | ||
| reused: string; | ||
| reused_in_bytes: number; | ||
| recovered: string; | ||
| recovered_in_bytes: number; | ||
| percent: string; | ||
| }; | ||
| files: { | ||
| total: number; | ||
| reused: number; | ||
| recovered: number; | ||
| percent: string; | ||
| }; | ||
| total_time: string; | ||
| total_time_in_millis: number; | ||
| source_throttle_time: string; | ||
| source_throttle_time_in_millis: number; | ||
| target_throttle_time: string; | ||
| target_throttle_time_in_millis: number; | ||
| }; | ||
| translog: { | ||
| recovered: number; | ||
| total: number; | ||
| percent: string; | ||
| total_on_start: number; | ||
| total_time: string; | ||
| total_time_in_millis: number; | ||
| }; | ||
| verify_index: { | ||
| check_index_time: string; | ||
| check_index_time_in_millis: number; | ||
| total_time: string; | ||
| total_time_in_millis: number; | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| export interface RestoreSettings { | ||
| indices?: string[]; | ||
| renamePattern?: string; | ||
| renameReplacement?: string; | ||
| includeGlobalState?: boolean; | ||
| partial?: boolean; | ||
| indexSettings?: string; | ||
| ignoreIndexSettings?: string[]; | ||
| } | ||
|
|
||
| export interface RestoreSettingsEs { | ||
| indices?: string[]; | ||
| rename_pattern?: string; | ||
| rename_replacement?: string; | ||
| include_global_state?: boolean; | ||
| partial?: boolean; | ||
| index_settings?: { [key: string]: any }; | ||
| ignore_index_settings?: string[]; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* | ||
| * Prevent switch controls from moving around when toggling content | ||
| */ | ||
| .snapshotRestore__restoreForm__stepLogistics, | ||
| .snapshotRestore__restoreForm__stepSettings { | ||
| .euiFormRow--hasEmptyLabelSpace { | ||
| min-height: auto; | ||
| margin-top: $euiFontSizeXS + $euiSizeS + ($euiSizeXXL / 4); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| export { RestoreSnapshotForm } from './restore_snapshot_form'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this second
describeis so similar to the first that it might just end up being noise in the terminal.