-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ILM] Read only view #186955
[ILM] Read only view #186955
Changes from 20 commits
9627765
7fc7e36
bde6e90
6909966
8517c55
3561b16
1aa43f0
04beb8f
648a6c2
b7fd5fd
3aedbf1
74de2cf
8fbfcd2
881c583
ac13f14
0045c12
71ec3ba
234f7e9
e4c14ec
c2a4747
ebde681
1aab402
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { PolicyFromES } from '../common/types'; | ||
|
||
export const policyAllPhases: PolicyFromES = { | ||
name: 'test', | ||
modifiedDate: '2024-08-12T12:17:06.271Z', | ||
version: 1, | ||
policy: { | ||
name: 'test', | ||
phases: { | ||
hot: { | ||
actions: { | ||
rollover: { | ||
max_age: '30d', | ||
max_primary_shard_size: '50gb', | ||
max_primary_shard_docs: 25, | ||
max_docs: 235, | ||
max_size: '2gb', | ||
}, | ||
set_priority: { | ||
priority: 100, | ||
}, | ||
forcemerge: { | ||
max_num_segments: 3, | ||
index_codec: 'best_compression', | ||
}, | ||
shrink: { | ||
number_of_shards: 1, | ||
}, | ||
readonly: {}, | ||
}, | ||
min_age: '0ms', | ||
}, | ||
warm: { | ||
min_age: '3d', | ||
actions: { | ||
set_priority: { | ||
priority: 50, | ||
}, | ||
shrink: { | ||
max_primary_shard_size: '4gb', | ||
}, | ||
forcemerge: { | ||
max_num_segments: 44, | ||
index_codec: 'best_compression', | ||
}, | ||
allocate: { | ||
number_of_replicas: 3, | ||
}, | ||
downsample: { | ||
fixed_interval: '1d', | ||
}, | ||
}, | ||
}, | ||
cold: { | ||
min_age: '55d', | ||
actions: { | ||
searchable_snapshot: { | ||
snapshot_repository: 'found-snapshots', | ||
}, | ||
set_priority: { | ||
priority: 0, | ||
}, | ||
allocate: { | ||
number_of_replicas: 3, | ||
}, | ||
downsample: { | ||
fixed_interval: '4d', | ||
}, | ||
}, | ||
}, | ||
frozen: { | ||
min_age: '555d', | ||
actions: { | ||
searchable_snapshot: { | ||
snapshot_repository: 'found-snapshots', | ||
}, | ||
}, | ||
}, | ||
delete: { | ||
min_age: '7365d', | ||
actions: { | ||
wait_for_snapshot: { | ||
policy: 'cloud-snapshot-policy', | ||
}, | ||
delete: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { ReactElement } from 'react'; | ||
import { mountWithIntl } from '@kbn/test-jest-helpers'; | ||
import { findTestSubject, takeMountedSnapshot } from '@elastic/eui/lib/test'; | ||
|
||
import { docLinksServiceMock } from '@kbn/core/public/mocks'; | ||
|
||
import type { PolicyFromES } from '../common/types'; | ||
import { KibanaContextProvider } from '../public/shared_imports'; | ||
import { PolicyListContextProvider } from '../public/application/sections/policy_list/policy_list_context'; | ||
import { ViewPolicyFlyout } from '../public/application/sections/policy_list/policy_flyout'; | ||
import * as readOnlyHook from '../public/application/lib/use_is_read_only'; | ||
import { policyAllPhases } from './mocks'; | ||
|
||
let component: ReactElement; | ||
const TestComponent = ({ policy }: { policy: PolicyFromES }) => { | ||
return ( | ||
<KibanaContextProvider | ||
services={{ getUrlForApp: () => '', docLinks: docLinksServiceMock.createStartContract() }} | ||
> | ||
<PolicyListContextProvider> | ||
<ViewPolicyFlyout policy={policy} /> | ||
</PolicyListContextProvider> | ||
</KibanaContextProvider> | ||
); | ||
}; | ||
|
||
describe('View policy flyout', () => { | ||
beforeAll(() => { | ||
jest.spyOn(readOnlyHook, 'useIsReadOnly').mockReturnValue(false); | ||
component = <TestComponent policy={policyAllPhases} />; | ||
}); | ||
it('shows all phases', () => { | ||
const rendered = mountWithIntl(component); | ||
expect(takeMountedSnapshot(rendered)).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders manage button', () => { | ||
const rendered = mountWithIntl(component); | ||
const button = findTestSubject(rendered, 'managePolicyButton'); | ||
expect(button.exists()).toBeTruthy(); | ||
}); | ||
|
||
it(`doesn't render manage button in read only view`, () => { | ||
jest.spyOn(readOnlyHook, 'useIsReadOnly').mockReturnValue(true); | ||
component = <TestComponent policy={policyAllPhases} />; | ||
const rendered = mountWithIntl(component); | ||
const button = findTestSubject(rendered, 'managePolicyButton'); | ||
expect(button.exists()).toBeFalsy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,21 +60,13 @@ export interface SerializedActionWithAllocation { | |
migrate?: MigrateAction; | ||
} | ||
|
||
export type SearchableSnapshotStorage = 'full_copy' | 'shared_cache'; | ||
|
||
export interface SearchableSnapshotAction { | ||
snapshot_repository: string; | ||
/** | ||
* We do not configure this value in the UI as it is an advanced setting that will | ||
* not suit the vast majority of cases. | ||
*/ | ||
force_merge_index?: boolean; | ||
/** | ||
* This configuration lets the user create full or partial searchable snapshots. | ||
* Full searchable snapshots store primary data locally and store replica data in the snapshot. | ||
* Partial searchable snapshots store no data locally. | ||
*/ | ||
storage?: SearchableSnapshotStorage; | ||
} | ||
|
||
export interface RolloverAction { | ||
|
@@ -96,9 +88,7 @@ export interface SerializedHotPhase extends SerializedPhase { | |
shrink?: ShrinkAction; | ||
downsample?: DownsampleAction; | ||
|
||
set_priority?: { | ||
priority: number | null; | ||
}; | ||
set_priority?: SetPriorityAction; | ||
/** | ||
* Only available on enterprise license | ||
*/ | ||
|
@@ -113,9 +103,7 @@ export interface SerializedWarmPhase extends SerializedPhase { | |
forcemerge?: ForcemergeAction; | ||
readonly?: {}; | ||
downsample?: DownsampleAction; | ||
set_priority?: { | ||
priority: number | null; | ||
}; | ||
set_priority?: SetPriorityAction; | ||
migrate?: MigrateAction; | ||
}; | ||
} | ||
|
@@ -126,9 +114,7 @@ export interface SerializedColdPhase extends SerializedPhase { | |
readonly?: {}; | ||
downsample?: DownsampleAction; | ||
allocate?: AllocateAction; | ||
set_priority?: { | ||
priority: number | null; | ||
}; | ||
set_priority?: SetPriorityAction; | ||
migrate?: MigrateAction; | ||
/** | ||
* Only available on enterprise license | ||
|
@@ -139,11 +125,6 @@ export interface SerializedColdPhase extends SerializedPhase { | |
|
||
export interface SerializedFrozenPhase extends SerializedPhase { | ||
actions: { | ||
allocate?: AllocateAction; | ||
set_priority?: { | ||
priority: number | null; | ||
}; | ||
migrate?: MigrateAction; | ||
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. Frozen phase doesn't allow these actions |
||
/** | ||
* Only available on enterprise license | ||
*/ | ||
|
@@ -187,11 +168,8 @@ export interface DownsampleAction { | |
fixed_interval: string; | ||
} | ||
|
||
export interface LegacyPolicy { | ||
name: string; | ||
phases: { | ||
delete: DeletePhase; | ||
}; | ||
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. another unused type |
||
export interface SetPriorityAction { | ||
priority: number | null; | ||
} | ||
|
||
export interface CommonPhaseSettings { | ||
|
@@ -203,44 +181,6 @@ export interface PhaseWithMinAge { | |
selectedMinimumAgeUnits: string; | ||
} | ||
|
||
export interface PhaseWithIndexPriority { | ||
phaseIndexPriority: string; | ||
} | ||
|
||
export interface PhaseWithForcemergeAction { | ||
forceMergeEnabled: boolean; | ||
selectedForceMergeSegments: string; | ||
bestCompressionEnabled: boolean; | ||
} | ||
|
||
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. unused types |
||
export interface DeletePhase extends CommonPhaseSettings, PhaseWithMinAge { | ||
waitForSnapshotPolicy: string; | ||
} | ||
|
||
export interface IndexLifecyclePolicy { | ||
index: string; | ||
managed: boolean; | ||
action?: string; | ||
action_time_millis?: number; | ||
age?: string; | ||
failed_step?: string; | ||
failed_step_retry_count?: number; | ||
is_auto_retryable_error?: boolean; | ||
lifecycle_date_millis?: number; | ||
phase?: string; | ||
phase_execution?: { | ||
policy: string; | ||
modified_date_in_millis: number; | ||
version: number; | ||
phase_definition: SerializedPhase; | ||
}; | ||
phase_time_millis?: number; | ||
policy?: string; | ||
step?: string; | ||
step_info?: { | ||
reason?: string; | ||
type?: string; | ||
message?: string; | ||
}; | ||
step_time_millis?: number; | ||
} | ||
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 type is replaced by a type from the js client |
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.
pretty sure, this type was a leftover from searchable snapshot implementation that we ended up not needing