From 04fce19d75a1f3dbc738e4344ccec1eb99541ed6 Mon Sep 17 00:00:00 2001 From: bowenlan-amzn Date: Thu, 3 Nov 2022 15:34:28 -0700 Subject: [PATCH] Fix the compatibility issue of awareness replica validation (#595) Addresses the breaking change in the OS_2.4 AwarenessReplicaBalance.validate() https://github.com/opensearch-project/index-management/issues/593 Signed-off-by: bowenlan-amzn --- .../action/indexpolicy/TransportIndexPolicyAction.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/indexpolicy/TransportIndexPolicyAction.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/indexpolicy/TransportIndexPolicyAction.kt index 2ff3e2b80..6d90429d9 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/indexpolicy/TransportIndexPolicyAction.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/indexpolicy/TransportIndexPolicyAction.kt @@ -19,6 +19,7 @@ import org.opensearch.action.support.ActionFilters import org.opensearch.action.support.HandledTransportAction import org.opensearch.action.support.master.AcknowledgedResponse import org.opensearch.client.node.NodeClient +import org.opensearch.cluster.metadata.AutoExpandReplicas import org.opensearch.cluster.routing.allocation.AwarenessReplicaBalance import org.opensearch.cluster.service.ClusterService import org.opensearch.common.ValidationException @@ -116,10 +117,13 @@ class TransportIndexPolicyAction @Inject constructor( @Suppress("ComplexMethod", "LongMethod", "NestedBlockDepth") private fun validate() { + // ISM doesn't support update auto expand replica setting, so initiate this as false + val autoExpandReplica = AutoExpandReplicas.SETTING[Settings.EMPTY] + request.policy.states.forEach { state -> state.actions.forEach { action -> if (action is ReplicaCountAction) { - val error = awarenessReplicaBalance.validate(action.numOfReplicas) + val error = awarenessReplicaBalance.validate(action.numOfReplicas, autoExpandReplica) if (error.isPresent) { val ex = ValidationException() ex.addValidationError(error.get())