Skip to content

Commit

Permalink
Fix constraint bug which allows more primary shards than average prim…
Browse files Browse the repository at this point in the history
…ary shards per index (opensearch-project#14908) (opensearch-project#14916)

(cherry picked from commit 3497081)

Signed-off-by: Gaurav Bafna <gbbafna@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: kkewwei <kkewwei@163.com>
  • Loading branch information
2 people authored and kkewwei committed Jul 24, 2024
1 parent ecc21de commit b8741e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static Predicate<Constraint.ConstraintParams> isPerIndexPrimaryShardsPerN
return (params) -> {
int perIndexPrimaryShardCount = params.getNode().numPrimaryShards(params.getIndex());
int perIndexAllowedPrimaryShardCount = (int) Math.ceil(params.getBalancer().avgPrimaryShardsPerNode(params.getIndex()));
return perIndexPrimaryShardCount > perIndexAllowedPrimaryShardCount;
return perIndexPrimaryShardCount >= perIndexAllowedPrimaryShardCount;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testPerIndexPrimaryShardsConstraint() {

assertEquals(0, constraints.weight(balancer, node, indexName));

perIndexPrimaryShardCount = 3;
perIndexPrimaryShardCount = 2;
when(node.numPrimaryShards(anyString())).thenReturn(perIndexPrimaryShardCount);
assertEquals(CONSTRAINT_WEIGHT, constraints.weight(balancer, node, indexName));

Expand Down

0 comments on commit b8741e1

Please sign in to comment.