Skip to content

Conversation

nicktindall
Copy link
Contributor

Closes: ES-11999

@nicktindall nicktindall added >non-issue :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) labels Sep 23, 2025
@elasticsearchmachine elasticsearchmachine added Team:Distributed Coordination Meta label for Distributed Coordination team v9.2.0 labels Sep 23, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

@nicktindall nicktindall requested review from mhl-b, DiannaHohensee and Copilot and removed request for mhl-b September 23, 2025 03:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies the WriteLoadConstraintDecider to always allow allocation of unassigned shards, regardless of node capacity constraints. The change prevents the decider from blocking initial shard assignments while still enforcing write load constraints for shard relocations.

  • Added early return for unassigned shards in the allocation decision logic
  • Enhanced test coverage with dedicated unassigned shard test case
  • Improved test infrastructure with pattern-based assertion helper

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
WriteLoadConstraintDecider.java Added check to always allow allocation of unassigned shards
WriteLoadConstraintDeciderTests.java Added test case for unassigned shards and improved test assertion infrastructure
Comments suppressed due to low confidence (2)

server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/WriteLoadConstraintDeciderTests.java:1

  • The hardcoded values in the error message pattern (0.99, 0.900000) make the test brittle. Consider using variables or extracting these values to constants to improve maintainability and reduce duplication with the test setup.
/*

server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/WriteLoadConstraintDeciderTests.java:1

  • Similar to the previous comment, this error message pattern contains multiple hardcoded values (0.900000, 0.89, 0.06250, 0.50000, 8) that should be extracted to constants or variables to improve test maintainability and reduce coupling with implementation details.
/*

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@nicktindall nicktindall requested a review from ywangd October 1, 2025 00:20
Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

"Unassigned shard should always be accepted",
writeLoadDecider.canAllocate(
testHarness.unassignedShardRouting,
testHarness.exceedingThresholdRoutingNode,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I guess we could random between exceeding and below threshold routingNodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4527995

Comment on lines +282 to +287
ShardRouting unassignedShardRouting = TestShardRouting.newShardRouting(
testShardId4Unassigned,
null,
true,
ShardRoutingState.UNASSIGNED
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We can randomly also add write load for this shard into ClusterInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, fixed in 4527995

nicktindall and others added 4 commits October 1, 2025 11:15
# Conflicts:
#	server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/WriteLoadConstraintDeciderTests.java
…igned' into ES_11999_always_return_YES_unassigned
@nicktindall nicktindall enabled auto-merge (squash) October 1, 2025 01:50
@nicktindall nicktindall merged commit bd0d1ac into elastic:main Oct 1, 2025
34 of 35 checks passed
@nicktindall nicktindall deleted the ES_11999_always_return_YES_unassigned branch October 1, 2025 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) >non-issue Team:Distributed Coordination Meta label for Distributed Coordination team v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants