Skip to content

Commit af2eaf2

Browse files
authored
Remove usage of index.shrink.source.* in 7.x (#33271)
We cut over to `index.resize.source.*` but still have these constants being public in `IndexMetaData`. Those Settings and constants are not needed in 7.x while we still need to keep the keys known to private settings since they might be part of the index settings of old indices. We can remove that in 8.0. Yet, we should remove the settings to make sure they are not used again.
1 parent 07faa0b commit af2eaf2

File tree

5 files changed

+20
-30
lines changed

5 files changed

+20
-30
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -485,22 +485,14 @@ public MappingMetaData mapping(String mappingType) {
485485
return mappings.get(mappingType);
486486
}
487487

488-
// we keep the shrink settings for BWC - this can be removed in 8.0
489-
// we can't remove in 7 since this setting might be baked into an index coming in via a full cluster restart from 6.0
490-
public static final String INDEX_SHRINK_SOURCE_UUID_KEY = "index.shrink.source.uuid";
491-
public static final String INDEX_SHRINK_SOURCE_NAME_KEY = "index.shrink.source.name";
492488
public static final String INDEX_RESIZE_SOURCE_UUID_KEY = "index.resize.source.uuid";
493489
public static final String INDEX_RESIZE_SOURCE_NAME_KEY = "index.resize.source.name";
494-
public static final Setting<String> INDEX_SHRINK_SOURCE_UUID = Setting.simpleString(INDEX_SHRINK_SOURCE_UUID_KEY);
495-
public static final Setting<String> INDEX_SHRINK_SOURCE_NAME = Setting.simpleString(INDEX_SHRINK_SOURCE_NAME_KEY);
496-
public static final Setting<String> INDEX_RESIZE_SOURCE_UUID = Setting.simpleString(INDEX_RESIZE_SOURCE_UUID_KEY,
497-
INDEX_SHRINK_SOURCE_UUID);
498-
public static final Setting<String> INDEX_RESIZE_SOURCE_NAME = Setting.simpleString(INDEX_RESIZE_SOURCE_NAME_KEY,
499-
INDEX_SHRINK_SOURCE_NAME);
490+
public static final Setting<String> INDEX_RESIZE_SOURCE_UUID = Setting.simpleString(INDEX_RESIZE_SOURCE_UUID_KEY);
491+
public static final Setting<String> INDEX_RESIZE_SOURCE_NAME = Setting.simpleString(INDEX_RESIZE_SOURCE_NAME_KEY);
500492

501493
public Index getResizeSourceIndex() {
502-
return INDEX_RESIZE_SOURCE_UUID.exists(settings) || INDEX_SHRINK_SOURCE_UUID.exists(settings)
503-
? new Index(INDEX_RESIZE_SOURCE_NAME.get(settings), INDEX_RESIZE_SOURCE_UUID.get(settings)) : null;
494+
return INDEX_RESIZE_SOURCE_UUID.exists(settings) ? new Index(INDEX_RESIZE_SOURCE_NAME.get(settings),
495+
INDEX_RESIZE_SOURCE_UUID.get(settings)) : null;
504496
}
505497

506498
/**

server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,7 @@ static void prepareResizeIndexSettings(
723723
.put(IndexMetaData.INDEX_ROUTING_INITIAL_RECOVERY_GROUP_SETTING.getKey() + "_id",
724724
Strings.arrayToCommaDelimitedString(nodesToAllocateOn.toArray()))
725725
// we only try once and then give up with a shrink index
726-
.put("index.allocation.max_retries", 1)
727-
// we add the legacy way of specifying it here for BWC. We can remove this once it's backported to 6.x
728-
.put(IndexMetaData.INDEX_SHRINK_SOURCE_NAME.getKey(), resizeSourceIndex.getName())
729-
.put(IndexMetaData.INDEX_SHRINK_SOURCE_UUID.getKey(), resizeSourceIndex.getUUID());
726+
.put("index.allocation.max_retries", 1);
730727
} else if (type == ResizeType.SPLIT) {
731728
validateSplitIndex(currentState, resizeSourceIndex.getName(), mappingKeys, resizeIntoName, indexSettingsBuilder.build());
732729
} else {

server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,10 @@ public boolean isPrivateSetting(String key) {
202202
case IndexMetaData.SETTING_VERSION_UPGRADED:
203203
case IndexMetaData.SETTING_INDEX_PROVIDED_NAME:
204204
case MergePolicyConfig.INDEX_MERGE_ENABLED:
205-
case IndexMetaData.INDEX_SHRINK_SOURCE_UUID_KEY:
206-
case IndexMetaData.INDEX_SHRINK_SOURCE_NAME_KEY:
205+
// we keep the shrink settings for BWC - this can be removed in 8.0
206+
// we can't remove in 7 since this setting might be baked into an index coming in via a full cluster restart from 6.0
207+
case "index.shrink.source.uuid":
208+
case "index.shrink.source.name":
207209
case IndexMetaData.INDEX_RESIZE_SOURCE_UUID_KEY:
208210
case IndexMetaData.INDEX_RESIZE_SOURCE_NAME_KEY:
209211
return true;

server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,19 @@ public void testSizeShrinkIndex() {
286286
metaBuilder.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT).put("index.uuid", "1234"))
287287
.numberOfShards(4).numberOfReplicas(0));
288288
metaBuilder.put(IndexMetaData.builder("target").settings(settings(Version.CURRENT).put("index.uuid", "5678")
289-
.put("index.shrink.source.name", "test").put("index.shrink.source.uuid", "1234")).numberOfShards(1).numberOfReplicas(0));
289+
.put(IndexMetaData.INDEX_RESIZE_SOURCE_NAME_KEY, "test").put(IndexMetaData.INDEX_RESIZE_SOURCE_UUID_KEY, "1234"))
290+
.numberOfShards(1)
291+
.numberOfReplicas(0));
290292
metaBuilder.put(IndexMetaData.builder("target2").settings(settings(Version.CURRENT).put("index.uuid", "9101112")
291-
.put("index.shrink.source.name", "test").put("index.shrink.source.uuid", "1234")).numberOfShards(2).numberOfReplicas(0));
293+
.put(IndexMetaData.INDEX_RESIZE_SOURCE_NAME_KEY, "test").put(IndexMetaData.INDEX_RESIZE_SOURCE_UUID_KEY, "1234"))
294+
.numberOfShards(2).numberOfReplicas(0));
292295
MetaData metaData = metaBuilder.build();
293296
RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
294297
routingTableBuilder.addAsNew(metaData.index("test"));
295298
routingTableBuilder.addAsNew(metaData.index("target"));
296299
routingTableBuilder.addAsNew(metaData.index("target2"));
297-
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
298-
.metaData(metaData).routingTable(routingTableBuilder.build()).build();
300+
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING
301+
.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTableBuilder.build()).build();
299302

300303
AllocationService allocationService = createAllocationService();
301304
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(newNode("node1")))
@@ -330,7 +333,6 @@ public void testSizeShrinkIndex() {
330333
assertEquals(100L, DiskThresholdDecider.getExpectedShardSize(test_1, allocation, 0));
331334
assertEquals(10L, DiskThresholdDecider.getExpectedShardSize(test_0, allocation, 0));
332335

333-
334336
ShardRouting target = ShardRouting.newUnassigned(new ShardId(new Index("target", "5678"), 0),
335337
true, LocalShardsRecoverySource.INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "foo"));
336338
assertEquals(1110L, DiskThresholdDecider.getExpectedShardSize(target, allocation, 0));
@@ -350,12 +352,9 @@ public void testSizeShrinkIndex() {
350352
.build();
351353

352354
allocationService.reroute(clusterState, "foo");
353-
354355
RoutingAllocation allocationWithMissingSourceIndex = new RoutingAllocation(null,
355356
clusterStateWithMissingSourceIndex.getRoutingNodes(), clusterStateWithMissingSourceIndex, info, 0);
356-
357357
assertEquals(42L, DiskThresholdDecider.getExpectedShardSize(target, allocationWithMissingSourceIndex, 42L));
358358
assertEquals(42L, DiskThresholdDecider.getExpectedShardSize(target2, allocationWithMissingSourceIndex, 42L));
359359
}
360-
361360
}

server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/FilterAllocationDeciderTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
import java.util.Arrays;
4343
import java.util.Collections;
4444

45-
import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_SHRINK_SOURCE_NAME;
46-
import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_SHRINK_SOURCE_UUID;
45+
import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_RESIZE_SOURCE_NAME;
46+
import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_RESIZE_SOURCE_UUID;
4747
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
4848
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
4949
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
@@ -151,8 +151,8 @@ private ClusterState createInitialClusterState(AllocationService service, Settin
151151
.putInSyncAllocationIds(1, Collections.singleton("aid1"))
152152
.build();
153153
metaData.put(sourceIndex, false);
154-
indexSettings.put(INDEX_SHRINK_SOURCE_UUID.getKey(), sourceIndex.getIndexUUID());
155-
indexSettings.put(INDEX_SHRINK_SOURCE_NAME.getKey(), sourceIndex.getIndex().getName());
154+
indexSettings.put(INDEX_RESIZE_SOURCE_UUID.getKey(), sourceIndex.getIndexUUID());
155+
indexSettings.put(INDEX_RESIZE_SOURCE_NAME.getKey(), sourceIndex.getIndex().getName());
156156
} else {
157157
sourceIndex = null;
158158
}

0 commit comments

Comments
 (0)