diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java index 0dfb4798bff1c..a180876685f9c 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java @@ -1026,7 +1026,7 @@ public static void updateReplicationStrategy( * @param nodeSettings node settings */ public static void updateRemoteStoreSettings(Settings.Builder settingsBuilder, Settings nodeSettings) { - if (isRemoteStoreAttributePresent(nodeSettings)) { + if (RemoteStoreNodeAttribute.isRemoteStoreAttributePresent(nodeSettings)) { settingsBuilder.put(SETTING_REMOTE_STORE_ENABLED, true) .put( SETTING_REMOTE_SEGMENT_STORE_REPOSITORY, diff --git a/server/src/main/java/org/opensearch/snapshots/RestoreService.java b/server/src/main/java/org/opensearch/snapshots/RestoreService.java index 6f504aaeb4630..980610d337a63 100644 --- a/server/src/main/java/org/opensearch/snapshots/RestoreService.java +++ b/server/src/main/java/org/opensearch/snapshots/RestoreService.java @@ -675,12 +675,19 @@ private String[] getIgnoreSettingsInternal() { private Settings getOverrideSettingsInternal() { final Settings.Builder settingsBuilder = Settings.builder(); - MetadataCreateIndexService.updateReplicationStrategy( - settingsBuilder, - request.indexSettings(), - clusterService.getSettings(), - null - ); + + // We will use whatever replication strategy provided by user or from snapshot metadata unless + // cluster is remote store enabled or user have restricted a specific replication type in the + // cluster. + if (RemoteStoreNodeAttribute.isRemoteStoreAttributePresent(clusterService.getSettings()) == true + || clusterSettings.get(IndicesService.CLUSTER_INDEX_RESTRICT_REPLICATION_TYPE_SETTING) == true) { + MetadataCreateIndexService.updateReplicationStrategy( + settingsBuilder, + request.indexSettings(), + clusterService.getSettings(), + null + ); + } // remote store settings needs to be overridden if the remote store feature is enabled in the // cluster where snapshot is being restored. MetadataCreateIndexService.updateRemoteStoreSettings(settingsBuilder, clusterService.getSettings());