Skip to content

Commit d915bcd

Browse files
committed
Handle allocation for NONE direction
Signed-off-by: Lakshya Taragi <lakshya.taragi@gmail.com>
1 parent 98009ed commit d915bcd

File tree

3 files changed

+159
-198
lines changed

3 files changed

+159
-198
lines changed

server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ public static void validateRefreshIntervalSettings(Settings requestSettings, Clu
16591659
* @param clusterSettings cluster setting
16601660
*/
16611661
static void validateTranslogDurabilitySettings(Settings requestSettings, ClusterSettings clusterSettings, Settings settings) {
1662-
if (isRemoteDataAttributePresent(settings) == false
1662+
if ((isRemoteDataAttributePresent(settings) == false && isMigratingToRemoteStore(clusterSettings) == false)
16631663
|| IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.exists(requestSettings) == false
16641664
|| clusterSettings.get(IndicesService.CLUSTER_REMOTE_INDEX_RESTRICT_ASYNC_DURABILITY_SETTING) == false) {
16651665
return;

server/src/main/java/org/opensearch/cluster/routing/allocation/decider/RemoteStoreMigrationAllocationDecider.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,24 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
9595
);
9696
}
9797

98-
if (migrationDirection.equals(Direction.REMOTE_STORE) == false) {
99-
// docrep migration direction is currently not supported
98+
IndexMetadata indexMetadata = allocation.metadata().getIndexSafe(shardRouting.index());
99+
boolean remoteStoreBackedIndex = IndexMetadata.INDEX_REMOTE_STORE_ENABLED_SETTING.get(indexMetadata.getSettings());
100+
101+
if (migrationDirection.equals(Direction.NONE)) {
102+
boolean isNoDecision = (remoteStoreBackedIndex && targetNode.isRemoteStoreNode() == false)
103+
|| (remoteStoreBackedIndex == false && targetNode.isRemoteStoreNode());
104+
String reason = String.format(Locale.ROOT, " for %sremote store backed index", remoteStoreBackedIndex ? "" : "non ");
100105
return allocation.decision(
101-
Decision.YES,
106+
isNoDecision ? Decision.NO : Decision.YES,
102107
NAME,
103-
getDecisionDetails(true, shardRouting, targetNode, " for non remote_store direction")
108+
getDecisionDetails(!isNoDecision, shardRouting, targetNode, reason)
104109
);
110+
} else if (migrationDirection.equals(Direction.DOCREP)) {
111+
// docrep migration direction is currently not supported
112+
return allocation.decision(Decision.YES, NAME, getDecisionDetails(true, shardRouting, targetNode, " for DOCREP direction"));
105113
}
106114

107115
// check for remote store backed indices
108-
IndexMetadata indexMetadata = allocation.metadata().getIndexSafe(shardRouting.index());
109-
boolean remoteStoreBackedIndex = IndexMetadata.INDEX_REMOTE_STORE_ENABLED_SETTING.get(indexMetadata.getSettings());
110116
if (remoteStoreBackedIndex && targetNode.isRemoteStoreNode() == false) {
111117
// allocations and relocations must be to a remote node
112118
String reason = String.format(

0 commit comments

Comments
 (0)