Skip to content

Commit 6e4d8bf

Browse files
authored
Do not inject MigrateAction if it is not supported (#89457)
In #61377 we introduced a feature to let ILM migrate data between tiers. We achived this by inject a MigrateAction in `warm` and `cold` phase. However we also injected this action to phases where it is not supported such as `hot`, `frozen` and `delete` phase. It's better to no inject MigrateAction even though MigrateAction in these phases will be filtered out in `TimeseriesLifecycleType#getOrderedActions(Phase)` . This pr updates the `TimeseriesLifecycleType#shouldInjectMigrateStepForPhase(Phase)` to not inject MigrateAction for phase in which MigrateAction is not supported.
1 parent e582032 commit 6e4d8bf

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java

+9
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,20 @@ public List<Phase> getOrderedPhases(Map<String, Phase> phases) {
154154
}
155155

156156
public static boolean shouldInjectMigrateStepForPhase(Phase phase) {
157+
if (ALLOWED_ACTIONS.containsKey(phase.getName()) == false) {
158+
return false;
159+
}
160+
157161
// searchable snapshots automatically set their own allocation rules, no need to configure them with a migrate step.
158162
if (phase.getActions().get(SearchableSnapshotAction.NAME) != null) {
159163
return false;
160164
}
161165

166+
// do not inject if MigrateAction is not supported for this phase (such as hot, frozen, delete phase)
167+
if (ALLOWED_ACTIONS.get(phase.getName()).contains(MigrateAction.NAME) == false) {
168+
return false;
169+
}
170+
162171
// if the user configured the {@link MigrateAction} already we won't automatically configure it
163172
if (phase.getActions().get(MigrateAction.NAME) != null) {
164173
return false;

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleTypeTests.java

+23
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,29 @@ public void testShouldMigrateDataToTiers() {
843843
assertThat(TimeseriesLifecycleType.shouldInjectMigrateStepForPhase(phase), is(false));
844844
}
845845

846+
{
847+
// not inject in hot phase
848+
Phase phase = new Phase(HOT_PHASE, TimeValue.ZERO, Collections.emptyMap());
849+
assertThat(TimeseriesLifecycleType.shouldInjectMigrateStepForPhase(phase), is(false));
850+
}
851+
852+
{
853+
// not inject in frozen phase
854+
Phase phase = new Phase(FROZEN_PHASE, TimeValue.ZERO, Collections.emptyMap());
855+
assertThat(TimeseriesLifecycleType.shouldInjectMigrateStepForPhase(phase), is(false));
856+
}
857+
858+
{
859+
// not inject in delete phase
860+
Phase phase = new Phase(DELETE_PHASE, TimeValue.ZERO, Collections.emptyMap());
861+
assertThat(TimeseriesLifecycleType.shouldInjectMigrateStepForPhase(phase), is(false));
862+
}
863+
864+
{
865+
// return false for invalid phase
866+
Phase phase = new Phase(HOT_PHASE + randomAlphaOfLength(5), TimeValue.ZERO, Collections.emptyMap());
867+
assertThat(TimeseriesLifecycleType.shouldInjectMigrateStepForPhase(phase), is(false));
868+
}
846869
}
847870

848871
public void testValidatingSearchableSnapshotRepos() {

0 commit comments

Comments
 (0)