Skip to content

Commit 865704b

Browse files
authored
Updated the validation for search only replica settings (#17093)
* Updated the validation for search only replica settings Signed-off-by: Vinay Krishna Pudyodu <[email protected]> * Added Changelog and fixed style issues Signed-off-by: Vinay Krishna Pudyodu <[email protected]> * Removed the tests as its already covered in SearchOnlyReplicaTests Signed-off-by: Vinay Krishna Pudyodu <[email protected]> * Removed the changelog entry as there is not userfacing changes Signed-off-by: Vinay Krishna Pudyodu <[email protected]> --------- Signed-off-by: Vinay Krishna Pudyodu <[email protected]>
1 parent b82ed5a commit 865704b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

+7-8
Original file line numberDiff line numberDiff line change
@@ -1055,9 +1055,6 @@ static Settings aggregateIndexSettings(
10551055

10561056
updateReplicationStrategy(indexSettingsBuilder, request.settings(), settings, combinedTemplateSettings, clusterSettings);
10571057
updateRemoteStoreSettings(indexSettingsBuilder, currentState, clusterSettings, settings, request.index());
1058-
if (FeatureFlags.isEnabled(FeatureFlags.READER_WRITER_SPLIT_EXPERIMENTAL_SETTING)) {
1059-
updateSearchOnlyReplicas(request.settings(), indexSettingsBuilder);
1060-
}
10611058

10621059
if (sourceMetadata != null) {
10631060
assert request.resizeType() != null;
@@ -1094,18 +1091,20 @@ static Settings aggregateIndexSettings(
10941091
validateRefreshIntervalSettings(request.settings(), clusterSettings);
10951092
validateTranslogFlushIntervalSettingsForCompositeIndex(request.settings(), clusterSettings);
10961093
validateTranslogDurabilitySettings(request.settings(), clusterSettings, settings);
1094+
if (FeatureFlags.isEnabled(FeatureFlags.READER_WRITER_SPLIT_EXPERIMENTAL_SETTING)) {
1095+
validateSearchOnlyReplicasSettings(indexSettings);
1096+
}
10971097
return indexSettings;
10981098
}
10991099

1100-
private static void updateSearchOnlyReplicas(Settings requestSettings, Settings.Builder builder) {
1101-
if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING.exists(builder) && builder.get(SETTING_NUMBER_OF_SEARCH_REPLICAS) != null) {
1102-
if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING.get(requestSettings) > 0
1103-
&& Boolean.parseBoolean(builder.get(SETTING_REMOTE_STORE_ENABLED)) == false) {
1100+
private static void validateSearchOnlyReplicasSettings(Settings indexSettings) {
1101+
if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING.exists(indexSettings) && indexSettings.get(SETTING_NUMBER_OF_SEARCH_REPLICAS) != null) {
1102+
if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING.get(indexSettings) > 0
1103+
&& Boolean.parseBoolean(indexSettings.get(SETTING_REMOTE_STORE_ENABLED)) == false) {
11041104
throw new IllegalArgumentException(
11051105
"To set " + SETTING_NUMBER_OF_SEARCH_REPLICAS + ", " + SETTING_REMOTE_STORE_ENABLED + " must be set to true"
11061106
);
11071107
}
1108-
builder.put(SETTING_NUMBER_OF_SEARCH_REPLICAS, INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING.get(requestSettings));
11091108
}
11101109
}
11111110

0 commit comments

Comments
 (0)