Skip to content

Add index setting to bypass auto allocation to hot nodes #62114

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

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ public void testDefaultAllocateToHot() {
ensureYellow(index);
}

public void testBypassAutoAllocationToHot() throws Exception {
startWarmOnlyNode();
startColdOnlyNode();
ensureGreen();

client().admin().indices().prepareCreate(index)
.setSettings(Settings.builder()
.put(DataTier.INDEX_BYPASS_AUTO_DATA_TIER_ROUTING, true))
.setWaitForActiveShards(0)
.get();

Settings idxSettings = client().admin().indices().prepareGetIndex().addIndices(index).get().getSettings().get(index);
assertThat(DataTierAllocationDecider.INDEX_ROUTING_INCLUDE_SETTING.get(idxSettings), equalTo(""));

assertBusy(() ->
assertThat(client().admin().cluster().prepareHealth(index).get().getIndices().get(index).getStatus(),
equalTo(ClusterHealthStatus.GREEN))
);
}

public void testOverrideDefaultAllocation() {
startWarmOnlyNode();
startColdOnlyNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
*/
public class DataTier {

public static final String INDEX_BYPASS_AUTO_DATA_TIER_ROUTING = "index.bypass.auto.data_tier.routing";
/**
* Provides an opt-out of the automatically allocation of indices to hot nodes system and ILM auto migration of
* managed indices to the corresponding data tiers.
*/
public static final Setting<Boolean> INDEX_BYPASS_AUTO_DATA_TIER_ROUTING_SETTING =
Setting.boolSetting(INDEX_BYPASS_AUTO_DATA_TIER_ROUTING, false, Setting.Property.Dynamic, Setting.Property.IndexScope);

public static final String DATA_HOT = "data_hot";
public static final String DATA_WARM = "data_warm";
public static final String DATA_COLD = "data_cold";
Expand Down Expand Up @@ -156,6 +164,10 @@ public static class DefaultHotAllocationSettingProvider implements IndexSettingP
@Override
public Settings getAdditionalIndexSettings(String indexName, Settings indexSettings) {
Set<String> settings = indexSettings.keySet();
if (INDEX_BYPASS_AUTO_DATA_TIER_ROUTING_SETTING.get(indexSettings)) {
return Settings.EMPTY;
}

if (settings.contains(DataTierAllocationDecider.INDEX_ROUTING_INCLUDE)) {
// It's okay to put it, it will be removed or overridden by the template/request settings
return Settings.builder().put(DataTierAllocationDecider.INDEX_ROUTING_INCLUDE, DATA_HOT).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ public List<Setting<?>> getSettings() {
settings.add(DataTierAllocationDecider.INDEX_ROUTING_REQUIRE_SETTING);
settings.add(DataTierAllocationDecider.INDEX_ROUTING_INCLUDE_SETTING);
settings.add(DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE_SETTING);
settings.add(DataTier.INDEX_BYPASS_AUTO_DATA_TIER_ROUTING_SETTING);
return settings;
}

Expand Down