From 6b2ed1336a94c488a1071f5660a14cd69f4d634c Mon Sep 17 00:00:00 2001 From: Andrei Dan Date: Tue, 8 Sep 2020 16:30:14 +0100 Subject: [PATCH] Add index setting to bypass auto allocation to hot nodes This adds an index setting to allow opting out of automatic index allocation to the hot node, and eventually from automatically ILM index migration between data tiers --- .../routing/allocation/DataTierIT.java | 20 +++++++++++++++++++ .../elasticsearch/xpack/core/DataTier.java | 12 +++++++++++ .../elasticsearch/xpack/core/XPackPlugin.java | 1 + 3 files changed, 33 insertions(+) rename x-pack/plugin/core/src/{test => internalClusterTest}/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierIT.java (92%) diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierIT.java b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierIT.java similarity index 92% rename from x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierIT.java rename to x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierIT.java index d20c7169d3cca..57a36dbc551fc 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierIT.java +++ b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierIT.java @@ -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(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTier.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTier.java index e0c876e561a86..b9016dc3071e1 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTier.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTier.java @@ -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 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"; @@ -156,6 +164,10 @@ public static class DefaultHotAllocationSettingProvider implements IndexSettingP @Override public Settings getAdditionalIndexSettings(String indexName, Settings indexSettings) { Set 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(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java index 387a29fff3ba3..9e46e7466fb33 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java @@ -373,6 +373,7 @@ public List> 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; }