Skip to content

Commit

Permalink
Fix the compatibility issue of awareness replica validation (opensear…
Browse files Browse the repository at this point in the history
…ch-project#595) (opensearch-project#596)

Addresses the breaking change in the OS_2.4 AwarenessReplicaBalance.validate()

opensearch-project#593

Signed-off-by: bowenlan-amzn <[email protected]>
(cherry picked from commit 04fce19)

Co-authored-by: bowenlan-amzn <[email protected]>
Signed-off-by: Ronnak Saxena <[email protected]>
  • Loading branch information
2 people authored and ronnaksaxena committed Jul 19, 2023
1 parent d5e6bee commit 610aeb6
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 610aeb6

Please sign in to comment.