Skip to content

Commit b04a45e

Browse files
committed
Allow changing number of replicas of searchable snapshot index
Signed-off-by: panguixin <[email protected]>
1 parent ed1c8b7 commit b04a45e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

server/src/internalClusterTest/java/org/opensearch/snapshots/SearchableSnapshotIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,9 @@ private void testUpdateIndexSettingsOnlyNotAllowedSettings(String index) {
458458

459459
private void testUpdateIndexSettingsOnlyAllowedSettings(String index) {
460460
final UpdateSettingsRequestBuilder builder = client().admin().indices().prepareUpdateSettings(index);
461-
builder.setSettings(Map.of("index.max_result_window", 1000, "index.search.slowlog.threshold.query.warn", "10s"));
461+
builder.setSettings(
462+
Map.of("index.max_result_window", 1000, "index.search.slowlog.threshold.query.warn", "10s", "index.number_of_replicas", 0)
463+
);
462464
AcknowledgedResponse settingsResponse = builder.execute().actionGet();
463465
assertThat(settingsResponse, notNullValue());
464466
}

server/src/main/java/org/opensearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.opensearch.transport.TransportService;
5656

5757
import java.io.IOException;
58+
import java.util.Arrays;
5859
import java.util.Set;
5960
import java.util.stream.Stream;
6061

@@ -77,7 +78,8 @@ public class TransportUpdateSettingsAction extends TransportClusterManagerNodeAc
7778
"index.max_script_fields",
7879
"index.max_terms_count",
7980
"index.max_regex_length",
80-
"index.highlight.max_analyzed_offset"
81+
"index.highlight.max_analyzed_offset",
82+
"index.number_of_replicas"
8183
);
8284

8385
private final static String[] ALLOWLIST_REMOTE_SNAPSHOT_SETTINGS_PREFIXES = { "index.search.slowlog" };
@@ -145,10 +147,10 @@ protected ClusterBlockException checkBlock(UpdateSettingsRequest request, Cluste
145147
}
146148
}
147149

150+
final String[] requestIndexNames = Arrays.stream(requestIndices).map(Index::getName).toArray(String[]::new);
148151
return allowSearchableSnapshotSettingsUpdate
149152
? null
150-
: state.blocks()
151-
.indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indexNameExpressionResolver.concreteIndexNames(state, request));
153+
: state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, requestIndexNames);
152154
}
153155

154156
@Override

0 commit comments

Comments
 (0)