diff --git a/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java b/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java index 337c45e97ed91..c2eccdbc6ed26 100644 --- a/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java +++ b/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java @@ -41,8 +41,6 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.common.Strings; -import static org.opensearch.cluster.metadata.IndexMetadata.INDEX_AUTO_EXPAND_REPLICAS_SETTING; - /** * An allocation decider that prevents multiple instances of the same shard to * be allocated on the same {@code node}. @@ -95,10 +93,6 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing // if its already a NO decision looking at the node, or we aren't configured to look at the host, return the decision return decision; } - if (INDEX_AUTO_EXPAND_REPLICAS_SETTING.get(allocation.metadata().getIndexSafe(shardRouting.index()).getSettings()) - .autoExpandToAll()) { - return allocation.decision(Decision.YES, NAME, "allocation awareness is ignored, this index is set to auto-expand to all"); - } if (node.node() != null) { for (RoutingNode checkNode : allocation.routingNodes()) { if (checkNode.node() == null) { diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/SameShardRoutingTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/SameShardRoutingTests.java index 7ba199a3928ae..3bee0d994ebbc 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/SameShardRoutingTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/SameShardRoutingTests.java @@ -62,7 +62,6 @@ import static java.util.Collections.emptyMap; import static org.opensearch.cluster.routing.ShardRoutingState.INITIALIZING; -import static org.opensearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.opensearch.cluster.routing.allocation.RoutingNodesUtils.numberOfShardsOfType; import static org.hamcrest.Matchers.equalTo; @@ -188,60 +187,4 @@ public void testForceAllocatePrimaryOnSameNodeNotAllowed() { decision = decider.canForceAllocatePrimary(newPrimary, unassignedNode, routingAllocation); assertEquals(Decision.Type.YES, decision.type()); } - - public void testSameHostCheckIgnoredByAutoExpandReplicasToAll() { - final AllocationService strategy = createAllocationService( - Settings.builder().put(SameShardAllocationDecider.CLUSTER_ROUTING_ALLOCATION_SAME_HOST_SETTING.getKey(), true).build() - ); - - final Metadata metadata = Metadata.builder() - .put( - IndexMetadata.builder("test") - .settings( - settings(Version.CURRENT).put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 100) - .put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-all") - ) - ) - .build(); - - final ClusterState clusterState = applyStartedShardsUntilNoChange( - ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)) - .metadata(metadata) - .routingTable(RoutingTable.builder().addAsNew(metadata.index("test")).build()) - .nodes( - DiscoveryNodes.builder() - .add( - new DiscoveryNode( - "node1_name", - "node1", - "node1", - "test_host_1", - "test_host_address1", - buildNewFakeTransportAddress(), - emptyMap(), - CLUSTER_MANAGER_DATA_ROLES, - Version.CURRENT - ) - ) - .add( - new DiscoveryNode( - "node2_name", - "node2", - "node2", - "test_host_2", - "test_host_address2", - buildNewFakeTransportAddress(), - emptyMap(), - CLUSTER_MANAGER_DATA_ROLES, - Version.CURRENT - ) - ) - ) - .build(), - strategy - ); - - assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(0)); - } }