Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/137111.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 137111
summary: Remove `auto_expand_replicas` setting during index clone in `searchable_snapshot`
area: ILM+SLM
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ public class SearchableSnapshotAction implements LifecycleAction {
indexName,
state) -> state.forceMergeCloneIndexName() != null ? state.forceMergeCloneIndexName() : indexName;

private static final Settings CLONE_SETTINGS = Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).build();
/** The cloned index should have 0 replicas, so we also need to remove the auto_expand_replicas setting if present. */
private static final Settings CLONE_SETTINGS = Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, (String) null)
.build();
private static final Function<IndexMetadata, Settings> CLONE_SETTINGS_SUPPLIER = indexMetadata -> CLONE_SETTINGS;

private static final ConstructingObjectParser<SearchableSnapshotAction, Void> PARSER = new ConstructingObjectParser<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,11 +1033,17 @@ private String prepareDataStreamWithDocs(String phase, int numberOfPrimaries, in
createSnapshotRepo(client(), snapshotRepo, randomBoolean());
createNewSingletonPolicy(client(), policy, phase, new SearchableSnapshotAction(snapshotRepo, true));

final var indexSettings = indexSettings(numberOfPrimaries, numberOfReplicas);
// Randomly enable auto-expand replicas to test that we remove the setting for the clone with 0 replicas.
if (numberOfReplicas > 0 && randomBoolean()) {
logger.info("--> enabling auto-expand replicas on backing index");
indexSettings.put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "1-all");
}
createComposableTemplate(
client(),
randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT),
dataStream,
new Template(indexSettings(numberOfPrimaries, numberOfReplicas).build(), null, null)
new Template(indexSettings.build(), null, null)
);
for (int i = 0; i < randomIntBetween(5, 10); i++) {
indexDocument(client(), dataStream, true);
Expand Down