Skip to content
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] Fix the migrate to tiers service and migrate action tiers configuration #95934

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/95934.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 95934
summary: "[ILM] Fix the migrate to tiers service and migrate action tiers configuration"
area: ILM+SLM
type: bug
issues: []
6 changes: 2 additions & 4 deletions docs/reference/ilm/actions/ilm-migrate.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ to `data_cold,data_warm,data_hot`. This moves the index to nodes in the
The migrate action is not allowed in the frozen phase. The frozen phase directly
mounts the searchable snapshot using a
<<tier-preference-allocation-filter, `index.routing.allocation.include._tier_preference`>>
of `data_frozen,data_cold,data_warm,data_hot`. This moves the index to nodes in the
<<frozen-tier, frozen tier>>. If there are no nodes in the frozen tier, it falls back to the
<<cold-tier, cold>> tier, then the <<warm-tier, warm>> tier, then finally the <<hot-tier, hot>>
tier.
of `data_frozen`. This moves the index to nodes in the
<<frozen-tier, frozen tier>>.

The migrate action is not allowed in the hot phase.
The initial index allocation is performed <<data-tier-allocation, automatically>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,15 @@ public class DataTier {
final Map<String, Settings> tmpSettings = new HashMap<>();
for (int i = 0, ordered_frozen_to_hot_tiersSize = ORDERED_FROZEN_TO_HOT_TIERS.size(); i < ordered_frozen_to_hot_tiersSize; i++) {
String tier = ORDERED_FROZEN_TO_HOT_TIERS.get(i);
final String prefTierString = String.join(",", ORDERED_FROZEN_TO_HOT_TIERS.subList(i, ORDERED_FROZEN_TO_HOT_TIERS.size()))
.intern();
tmp.put(tier, prefTierString);
tmpSettings.put(tier, Settings.builder().put(DataTier.TIER_PREFERENCE, prefTierString).build());
if (tier.equals(DATA_FROZEN)) {
tmp.put(tier, DATA_FROZEN);
tmpSettings.put(DATA_FROZEN, Settings.builder().put(DataTier.TIER_PREFERENCE, DATA_FROZEN).build());
} else {
final String prefTierString = String.join(",", ORDERED_FROZEN_TO_HOT_TIERS.subList(i, ORDERED_FROZEN_TO_HOT_TIERS.size()))
.intern();
tmp.put(tier, prefTierString);
tmpSettings.put(tier, Settings.builder().put(DataTier.TIER_PREFERENCE, prefTierString).build());
}
}
PREFERENCE_TIER_CONFIGURATIONS = Map.copyOf(tmp);
PREFERENCE_TIER_CONFIGURATION_SETTINGS = Map.copyOf(tmpSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.concurrent.atomic.AtomicInteger;

import static org.elasticsearch.cluster.routing.allocation.DataTier.DATA_COLD;
import static org.elasticsearch.cluster.routing.allocation.DataTier.DATA_FROZEN;
import static org.elasticsearch.cluster.routing.allocation.DataTier.DATA_HOT;
import static org.elasticsearch.cluster.routing.allocation.DataTier.DATA_WARM;
import static org.elasticsearch.cluster.routing.allocation.DataTier.getPreferredTiersConfiguration;
Expand Down Expand Up @@ -120,6 +121,7 @@ public void testGetPreferredTiersConfiguration() {
assertThat(getPreferredTiersConfiguration(DATA_HOT), is(DATA_HOT));
assertThat(getPreferredTiersConfiguration(DATA_WARM), is(DATA_WARM + "," + DATA_HOT));
assertThat(getPreferredTiersConfiguration(DATA_COLD), is(DATA_COLD + "," + DATA_WARM + "," + DATA_HOT));
assertThat(getPreferredTiersConfiguration(DATA_FROZEN), is(DATA_FROZEN));
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> getPreferredTiersConfiguration("no_tier"));
assertThat(exception.getMessage(), is("invalid data tier [no_tier]"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void testMigrateIlmPolicyForIndexWithoutILMMetadata() {
assertThat(migratedColdAllocateAction.getRequire().size(), is(0));
}

public void testMigrateIlmPolicyFOrPhaseWithDeactivatedMigrateAction() {
public void testMigrateIlmPolicyForPhaseWithDeactivatedMigrateAction() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor typo fix

ShrinkAction shrinkAction = new ShrinkAction(2, null);
AllocateAction warmAllocateAction = new AllocateAction(null, null, Map.of("data", "warm"), null, Map.of("rack", "rack1"));

Expand Down Expand Up @@ -511,7 +511,7 @@ public void testAllocateActionDefinesRoutingRules() {
}

public void testConvertAttributeValueToTierPreference() {
assertThat(convertAttributeValueToTierPreference("frozen"), is("data_frozen,data_cold,data_warm,data_hot"));
assertThat(convertAttributeValueToTierPreference("frozen"), is("data_frozen"));
assertThat(convertAttributeValueToTierPreference("cold"), is("data_cold,data_warm,data_hot"));
assertThat(convertAttributeValueToTierPreference("warm"), is("data_warm,data_hot"));
assertThat(convertAttributeValueToTierPreference("hot"), is("data_hot"));
Expand Down Expand Up @@ -560,6 +560,26 @@ public void testMigrateIndices() {
assertThat(migratedIndex.getSettings().get(TIER_PREFERENCE), is("data_warm,data_hot"));
}

{
// test the migration of `include.data: frozen` configuration to the equivalent _tier_preference routing
IndexMetadata.Builder indexWithFrozenDataAttribute = IndexMetadata.builder("indexWithFrozenDataAttribute")
.settings(getBaseIndexSettings().put(DATA_ROUTING_INCLUDE_SETTING, "frozen"));
ClusterState state = ClusterState.builder(ClusterName.DEFAULT)
.metadata(Metadata.builder().put(indexWithFrozenDataAttribute))
.build();

Metadata.Builder mb = Metadata.builder(state.metadata());

List<String> migratedIndices = migrateIndices(mb, state, "data");
assertThat(migratedIndices.size(), is(1));
assertThat(migratedIndices.get(0), is("indexWithFrozenDataAttribute"));

ClusterState migratedState = ClusterState.builder(ClusterName.DEFAULT).metadata(mb).build();
IndexMetadata migratedIndex = migratedState.metadata().index("indexWithFrozenDataAttribute");
assertThat(migratedIndex.getSettings().get(DATA_ROUTING_INCLUDE_SETTING), nullValue());
assertThat(migratedIndex.getSettings().get(TIER_PREFERENCE), is("data_frozen"));
}

{
// since the index has a _tier_preference configuration the migrated index should still contain it and have ALL the `data`
// attributes routing removed
Expand Down