Skip to content

Commit c4e703f

Browse files
Allow changing number of replicas of searchable snapshot index (opensearch-project#11317)
* Allow changing number of replicas of searchable snapshot index Signed-off-by: panguixin <[email protected]> * add change log Signed-off-by: panguixin <[email protected]> --------- Signed-off-by: panguixin <[email protected]>
1 parent cb65c25 commit c4e703f

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
111111
- [Streaming Indexing] Introduce new experimental server HTTP transport based on Netty 4 and Project Reactor (Reactor Netty) ([#9672](https://github.com/opensearch-project/OpenSearch/pull/9672))
112112
- Add template snippets support for field and target_field in KV ingest processor ([#10040](https://github.com/opensearch-project/OpenSearch/pull/10040))
113113
- Allowing pipeline processors to access index mapping info by passing ingest service ref as part of the processor factory parameters ([#10307](https://github.com/opensearch-project/OpenSearch/pull/10307))
114+
- Allow changing number of replicas of searchable snapshot index ([#11317](https://github.com/opensearch-project/OpenSearch/pull/11317))
114115

115116
### Dependencies
116117
- Bump `com.google.api.grpc:proto-google-common-protos` from 2.10.0 to 2.25.1 ([#10208](https://github.com/opensearch-project/OpenSearch/pull/10208), [#10298](https://github.com/opensearch-project/OpenSearch/pull/10298))

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)