-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Restrict ILM frozen phase to searchable snapshot actions only #70158
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
Changes from all commits
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 |
---|---|---|
|
@@ -29,8 +29,8 @@ | |
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.elasticsearch.xpack.core.ilm.SearchableSnapshotActionTests.randomStorageType; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.instanceOf; | ||
import static org.mockito.Mockito.mock; | ||
|
@@ -128,7 +128,10 @@ public static LifecyclePolicy randomTimeseriesLifecyclePolicyWithAllPhases(@Null | |
|
||
public static LifecyclePolicy randomTimeseriesLifecyclePolicy(@Nullable String lifecycleName) { | ||
List<String> phaseNames = randomSubsetOf( | ||
between(0, TimeseriesLifecycleType.ORDERED_VALID_PHASES.size() - 1), TimeseriesLifecycleType.ORDERED_VALID_PHASES); | ||
between(0, TimeseriesLifecycleType.ORDERED_VALID_PHASES.size() - 1), TimeseriesLifecycleType.ORDERED_VALID_PHASES).stream() | ||
// Remove the frozen phase, we'll randomly re-add it later | ||
.filter(pn -> TimeseriesLifecycleType.FROZEN_PHASE.equals(pn) == false) | ||
.collect(Collectors.toList()); | ||
Map<String, Phase> phases = new HashMap<>(phaseNames.size()); | ||
Function<String, Set<String>> validActions = getPhaseToValidActions(); | ||
Function<String, LifecycleAction> randomAction = getNameToActionFunction(); | ||
|
@@ -189,6 +192,17 @@ public static LifecyclePolicy randomTimeseriesLifecyclePolicy(@Nullable String l | |
} | ||
phases.put(phase, new Phase(phase, after, actions)); | ||
} | ||
// Add a frozen phase if neither the hot nor cold phase contains a searchable snapshot action | ||
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. What is the connection between the hot/cold actions and the frozen phase? We're still able to have searchable_snapshot actions in all phases as far as I understand 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. It's mostly because we'd have to use a consistent repository name (or else validation would fail), we have enough validation that this gets more and more complex, and this doesn't have to generate all possible valid lifecycles, just a random one. |
||
if (hotPhaseContainsSearchableSnap == false && coldPhaseContainsSearchableSnap == false && randomBoolean()) { | ||
TimeValue frozenTime = prev == null ? TimeValue.parseTimeValue(randomTimeValue(0, 100000, "s", "m", "h", "d"), "test") : | ||
TimeValue.timeValueSeconds(prev.seconds() + randomIntBetween(60, 600)); | ||
phases.put(TimeseriesLifecycleType.FROZEN_PHASE, | ||
new Phase(TimeseriesLifecycleType.FROZEN_PHASE, frozenTime, | ||
Collections.singletonMap(SearchableSnapshotAction.NAME, | ||
new SearchableSnapshotAction(randomAlphaOfLength(10), randomBoolean())))); | ||
} else { | ||
phases.remove(TimeseriesLifecycleType.FROZEN_PHASE); | ||
} | ||
return new LifecyclePolicy(TimeseriesLifecycleType.INSTANCE, lifecycleName, phases); | ||
} | ||
|
||
|
@@ -234,7 +248,7 @@ private static Function<String, LifecycleAction> getNameToActionFunction() { | |
case UnfollowAction.NAME: | ||
return new UnfollowAction(); | ||
case SearchableSnapshotAction.NAME: | ||
return new SearchableSnapshotAction("repo", randomBoolean(), randomStorageType()); | ||
return new SearchableSnapshotAction("repo", randomBoolean()); | ||
case MigrateAction.NAME: | ||
return new MigrateAction(false); | ||
case RollupILMAction.NAME: | ||
|
@@ -269,8 +283,16 @@ protected LifecyclePolicy mutateInstance(LifecyclePolicy instance) throws IOExce | |
name = name + randomAlphaOfLengthBetween(1, 5); | ||
break; | ||
case 1: | ||
// Remove the frozen phase, because it makes a lot of invalid phases when randomly mutating an existing policy | ||
phases.remove(TimeseriesLifecycleType.FROZEN_PHASE); | ||
// Remove a random phase | ||
if (phases.size() > 0) { | ||
phases.remove(new ArrayList<>(phases.keySet()).remove(randomIntBetween(0, phases.size() - 1))); | ||
} | ||
String phaseName = randomValueOtherThanMany(phases::containsKey, | ||
() -> randomFrom(TimeseriesLifecycleType.ORDERED_VALID_PHASES)); | ||
() -> randomFrom(TimeseriesLifecycleType.ORDERED_VALID_PHASES.stream() | ||
.filter(pn -> TimeseriesLifecycleType.FROZEN_PHASE.equals(pn) == false) | ||
.collect(Collectors.toList()))); | ||
phases = new LinkedHashMap<>(phases); | ||
phases.put(phaseName, new Phase(phaseName, null, Collections.emptyMap())); | ||
break; | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
This is required because I am removing the serialization for 7.12 in a weird way (we don't usually remove things like this), once this has been backported all the way back to 7.12 I will re-enable BWC