From ff45ad12ac6aee77aa2c466e401c21138a1bd3a5 Mon Sep 17 00:00:00 2001 From: "ievgen.degtiarenko" Date: Wed, 11 Dec 2024 08:42:13 +0100 Subject: [PATCH] Update auto expand replicas This change updates serverless auto expand behaviour when stateless shard allocator is used. --- .../cluster/metadata/AutoExpandReplicas.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java b/server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java index ef28a46d423d..8fe45b2fa461 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java @@ -148,17 +148,12 @@ public static Map> getAutoExpandReplicaChanges( if (autoExpandReplicas.enabled() == false) { continue; } - // Special case for stateless indices: auto-expand is disabled, unless number_of_replicas has been set - // manually to 0 via index settings, which needs to be converted to 1. + // Special case for stateless indices: ensures there is always at least one replica. if (Objects.equals( indexMetadata.getSettings().get(ExistingShardsAllocator.EXISTING_SHARDS_ALLOCATOR_SETTING.getKey()), "stateless" )) { - if (indexMetadata.getNumberOfReplicas() == 0) { - nrReplicasChanged.computeIfAbsent(1, ArrayList::new).add(indexMetadata.getIndex().getName()); - } else { - continue; - } + autoExpandReplicas = new AutoExpandReplicas(1, autoExpandReplicas.maxReplicas(), true); } if (allocation == null) { allocation = allocationSupplier.get();