diff --git a/gradle/run.gradle b/gradle/run.gradle
index dc620900744e9..8b5f83d0b577f 100644
--- a/gradle/run.gradle
+++ b/gradle/run.gradle
@@ -47,7 +47,7 @@ testClusters {
}
setting 'opensearch.experimental.feature.read.write.split.enabled', 'true'
setting 'path.repo', '["/tmp/my-repo"]'
- setting 'node.attr.remote_store', 'true'
+ setting 'cluster.routing.allocation.enable', 'all'
setting 'cluster.remote_store.state.enabled', 'true'
setting 'node.attr.remote_store.segment.repository', 'my-repository'
setting 'node.attr.remote_store.translog.repository', 'my-repository'
diff --git a/server/src/main/java/org/opensearch/action/ActionModule.java b/server/src/main/java/org/opensearch/action/ActionModule.java
index 6913fad13ea5f..5afe6bb953f4c 100644
--- a/server/src/main/java/org/opensearch/action/ActionModule.java
+++ b/server/src/main/java/org/opensearch/action/ActionModule.java
@@ -688,9 +688,7 @@ public void reg
actions.register(AutoPutMappingAction.INSTANCE, TransportAutoPutMappingAction.class);
actions.register(IndicesAliasesAction.INSTANCE, TransportIndicesAliasesAction.class);
actions.register(UpdateSettingsAction.INSTANCE, TransportUpdateSettingsAction.class);
-
actions.register(SearchOnlyAction.INSTANCE, TransportSearchOnlyAction.class);
-
actions.register(AnalyzeAction.INSTANCE, TransportAnalyzeAction.class);
actions.register(PutIndexTemplateAction.INSTANCE, TransportPutIndexTemplateAction.class);
actions.register(GetIndexTemplatesAction.INSTANCE, TransportGetIndexTemplatesAction.class);
@@ -912,9 +910,7 @@ public void initRestHandlers(Supplier nodesInCluster) {
registerHandler.accept(new RestUpgradeAction());
registerHandler.accept(new RestUpgradeStatusAction());
registerHandler.accept(new RestClearIndicesCacheAction());
-
registerHandler.accept(new RestSearchonlyAction());
-
registerHandler.accept(new RestIndexAction());
registerHandler.accept(new CreateHandler());
registerHandler.accept(new AutoIdHandler(nodesInCluster));
diff --git a/server/src/main/java/org/opensearch/action/admin/indices/searchonly/SearchOnlyResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/searchonly/SearchOnlyResponse.java
index 8178a6b783bf2..54488aab71478 100644
--- a/server/src/main/java/org/opensearch/action/admin/indices/searchonly/SearchOnlyResponse.java
+++ b/server/src/main/java/org/opensearch/action/admin/indices/searchonly/SearchOnlyResponse.java
@@ -38,7 +38,7 @@ public SearchOnlyResponse(StreamInput in) throws IOException {
@Override
public void writeTo(StreamOutput out) throws IOException {
- out.writeList(new ArrayList<>(nodeResponses)); // Convert Collection to List
+ out.writeList(new ArrayList<>(nodeResponses));
out.writeBoolean(hasFailures);
out.writeOptionalString(failureReason);
}
diff --git a/server/src/main/java/org/opensearch/cluster/health/ClusterIndexHealth.java b/server/src/main/java/org/opensearch/cluster/health/ClusterIndexHealth.java
index 7791f5f9a795a..e38f90fd45e00 100644
--- a/server/src/main/java/org/opensearch/cluster/health/ClusterIndexHealth.java
+++ b/server/src/main/java/org/opensearch/cluster/health/ClusterIndexHealth.java
@@ -254,18 +254,8 @@ public ClusterIndexHealth(
}
}
ShardRouting primaryShard = indexShardRoutingTable.primaryShard();
- /*if (primaryShard.active()) {
- computeActivePrimaryShards++;
- }
- ClusterHealthStatus shardHealth = ClusterShardHealth.getShardHealth(
- primaryShard,
- activeShardsPerShardId,
- shardRoutingCountPerShardId
- );
- computeStatus = getIndexHealthStatus(shardHealth, computeStatus);*/
if (primaryShard == null) {
- // 3. If there is no primary shard:
if (isSearchOnlyEnabled) {
computeStatus = getIndexHealthStatus(ClusterHealthStatus.GREEN, computeStatus);
} else {
diff --git a/server/src/main/java/org/opensearch/cluster/health/ClusterShardHealth.java b/server/src/main/java/org/opensearch/cluster/health/ClusterShardHealth.java
index ce9a67911cfdb..e1dbe8e5343f6 100644
--- a/server/src/main/java/org/opensearch/cluster/health/ClusterShardHealth.java
+++ b/server/src/main/java/org/opensearch/cluster/health/ClusterShardHealth.java
@@ -32,6 +32,7 @@
package org.opensearch.cluster.health;
+import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.cluster.routing.IndexShardRoutingTable;
import org.opensearch.cluster.routing.RecoverySource;
import org.opensearch.cluster.routing.ShardRouting;
@@ -230,7 +231,12 @@ public void writeTo(final StreamOutput out) throws IOException {
* Shard health is RED when the primary is not active.
*
*/
- public static ClusterHealthStatus getShardHealth(final ShardRouting primaryRouting, final int activeShards, final int totalShards) {
+ public static ClusterHealthStatus getShardHealth(
+ final ShardRouting primaryRouting,
+ final int activeShards,
+ final int totalShards
+ ) {
+ // TO DO
// assert primaryRouting != null : "Primary shard routing can't be null";
if (primaryRouting.active()) {
if (activeShards == totalShards) {
@@ -243,6 +249,7 @@ public static ClusterHealthStatus getShardHealth(final ShardRouting primaryRouti
}
}
+
/**
* Checks if an inactive primary shard should cause the cluster health to go RED.
*
diff --git a/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java b/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java
index 2c273bd83fcb1..e648115884941 100644
--- a/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java
+++ b/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java
@@ -575,14 +575,8 @@ public static APIBlock readFrom(StreamInput input) throws IOException {
public static final String SETTING_READ_ONLY_ALLOW_DELETE = APIBlock.READ_ONLY_ALLOW_DELETE.settingName();
public static final Setting INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING = APIBlock.READ_ONLY_ALLOW_DELETE.setting();
-
- // public static final String SETTING_BLOCKS_SEARCH_ONLY = APIBlock.SEARCH_ONLY.settingName();
- // public static final Setting INDEX_BLOCKS_SEARCH_ONLY_SETTING = APIBlock.SEARCH_ONLY.setting();
-
-
public static final Setting INDEX_BLOCKS_SEARCH_ONLY_SETTING = APIBlock.SEARCH_ONLY.setting();
-
public static final String SETTING_VERSION_CREATED = "index.version.created";
public static final Setting SETTING_INDEX_VERSION_CREATED = Setting.versionSetting(
diff --git a/server/src/main/java/org/opensearch/cluster/routing/RoutingNodes.java b/server/src/main/java/org/opensearch/cluster/routing/RoutingNodes.java
index 346282fc740d3..dea6b037c1fe5 100644
--- a/server/src/main/java/org/opensearch/cluster/routing/RoutingNodes.java
+++ b/server/src/main/java/org/opensearch/cluster/routing/RoutingNodes.java
@@ -127,6 +127,7 @@ public RoutingNodes(ClusterState clusterState, boolean readOnly) {
// also fill replicaSet information
for (final IndexRoutingTable indexRoutingTable : routingTable.indicesRouting().values()) {
for (IndexShardRoutingTable indexShard : indexRoutingTable) {
+ // TO DO
// assert indexShard.primary != null;
for (ShardRouting shard : indexShard) {
// to get all the shards belonging to an index, including the replicas,
@@ -183,8 +184,13 @@ private void updateRecoveryCounts(final ShardRouting routing, final boolean incr
final int howMany = increment ? 1 : -1;
assert routing.initializing() : "routing must be initializing: " + routing;
+
+ boolean isSearchOnly = metadata.index(routing.index()).getSettings().getAsBoolean(IndexMetadata.INDEX_BLOCKS_SEARCH_ONLY_SETTING.getKey(), false);
// TODO: check primary == null || primary.active() after all tests properly add ReplicaAfterPrimaryActiveAllocationDecider
- // assert primary == null || primary.assignedToNode() : "shard is initializing but its primary is not assigned to a node";
+ if (!isSearchOnly) {
+ assert primary == null || primary.assignedToNode()
+ : "shard is initializing but its primary is not assigned to a node";
+ }
// Primary shard routing, excluding the relocating primaries.
if (routing.primary() && (primary == null || primary == routing)) {
diff --git a/server/src/main/java/org/opensearch/cluster/routing/ShardRouting.java b/server/src/main/java/org/opensearch/cluster/routing/ShardRouting.java
index 14d9e1163fdf2..5257de3427d7c 100644
--- a/server/src/main/java/org/opensearch/cluster/routing/ShardRouting.java
+++ b/server/src/main/java/org/opensearch/cluster/routing/ShardRouting.java
@@ -33,6 +33,7 @@
package org.opensearch.cluster.routing;
import org.opensearch.Version;
+import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.cluster.routing.RecoverySource.ExistingStoreRecoverySource;
import org.opensearch.cluster.routing.RecoverySource.PeerRecoverySource;
import org.opensearch.cluster.routing.allocation.allocator.BalancedShardsAllocator;
@@ -115,6 +116,7 @@ protected ShardRouting(
assert !(state == ShardRoutingState.UNASSIGNED && unassignedInfo == null) : "unassigned shard must be created with meta";
assert (state == ShardRoutingState.UNASSIGNED || state == ShardRoutingState.INITIALIZING) == (recoverySource != null)
: "recovery source only available on unassigned or initializing shard but was " + state;
+ // TO DO
/*assert recoverySource == null || recoverySource == PeerRecoverySource.INSTANCE || primary || searchOnly
: "replica shards always recover from primary";*/
assert (currentNodeId == null) == (state == ShardRoutingState.UNASSIGNED) : "unassigned shard must not be assigned to a node "
diff --git a/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/ReplicaAfterPrimaryActiveAllocationDecider.java b/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/ReplicaAfterPrimaryActiveAllocationDecider.java
index 0f07420e21a3e..6349189e7186e 100644
--- a/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/ReplicaAfterPrimaryActiveAllocationDecider.java
+++ b/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/ReplicaAfterPrimaryActiveAllocationDecider.java
@@ -57,10 +57,6 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocat
return allocation.decision(Decision.YES, NAME, "shard is primary and can be allocated");
}
ShardRouting primary = allocation.routingNodes().activePrimary(shardRouting.shardId());
- // Added this
- /*if (primary == null && !shardRouting.isSearchOnly()) {
- return allocation.decision(Decision.NO, NAME, "primary shard for this replica is not yet active");
- }*/
if (primary == null) {
boolean indexIsSearchOnly = allocation.metadata()
.getIndexSafe(shardRouting.index())
diff --git a/server/src/main/java/org/opensearch/common/settings/IndexScopedSettings.java b/server/src/main/java/org/opensearch/common/settings/IndexScopedSettings.java
index ca5c672b40300..4ddf2a0ef3309 100644
--- a/server/src/main/java/org/opensearch/common/settings/IndexScopedSettings.java
+++ b/server/src/main/java/org/opensearch/common/settings/IndexScopedSettings.java
@@ -230,8 +230,7 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
IndexSettings.SEARCHABLE_SNAPSHOT_ID_UUID,
IndexSettings.SEARCHABLE_SNAPSHOT_SHARD_PATH_TYPE,
-
- // Search only setting
+ // Index Search only setting
IndexSettings.INDEX_SEARCH_ONLY_SETTING,
// Settings for remote translog
diff --git a/server/src/main/java/org/opensearch/gateway/ReplicaShardAllocator.java b/server/src/main/java/org/opensearch/gateway/ReplicaShardAllocator.java
index 5b790d702e95b..3e4d0a0d88ab1 100644
--- a/server/src/main/java/org/opensearch/gateway/ReplicaShardAllocator.java
+++ b/server/src/main/java/org/opensearch/gateway/ReplicaShardAllocator.java
@@ -229,7 +229,6 @@ public AllocateUnassignedDecision makeAllocationDecision(
return getAllocationDecision(unassignedShard, allocation, nodeShardStores, result, logger);
}
- // Added this
protected AllocateUnassignedDecision getAllocationDecision(
ShardRouting unassignedShard,
RoutingAllocation allocation,
@@ -254,6 +253,7 @@ protected AllocateUnassignedDecision getAllocationDecision(
if (primaryShard == null) {
// Determine if the index is configured for search-only.
+
boolean isIndexSearchOnly = allocation.metadata()
.getIndexSafe(unassignedShard.index())
.getSettings()
@@ -284,15 +284,6 @@ protected AllocateUnassignedDecision getAllocationDecision(
return AllocateUnassignedDecision.yes(selectedCandidate, null, new ArrayList<>(), false);
}
- /* force methad an allocation using the first available data node.
- if (!dataNodes.isEmpty()) {
- // forcibly picks the first node
- DiscoveryNode forcedCandidate = dataNodes.iterator().next();
- logger.info("Forcing allocation of search-only replica {} to node {} because no candidate qualified normally", unassignedShard, forcedCandidate);
- return AllocateUnassignedDecision.yes(forcedCandidate, null, new ArrayList<>(), false);
- }*/
-
-
// If there are no data nodes available, delay allocation.
return AllocateUnassignedDecision.delayed(0L, 0L, null);
} else {
diff --git a/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java b/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java
index 9fa575a18a0e1..c323b9c56106a 100644
--- a/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java
+++ b/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java
@@ -74,7 +74,6 @@ public void getCheckpointMetadata(
return;
}
- // Added this
if (mdFile == null) {
listener.onResponse(new CheckpointInfoResponse(indexShard.getLatestReplicationCheckpoint(), Collections.emptyMap(), null));
} else {