Skip to content

Conversation

@DiannaHohensee
Copy link
Contributor

@DiannaHohensee DiannaHohensee commented Oct 30, 2025

Add MoveDecision#cannotRemain() to replace
the numerous canRemain() == false checks

Rename Balancer#decideRebalance() to
Balancer#explainRebalanceDecision()

Rename a Decision canRemain variable to
Decision canRemainDecision so it doesn't
sound like a boolean

Relates ES-12833

@DiannaHohensee DiannaHohensee self-assigned this Oct 30, 2025
@DiannaHohensee DiannaHohensee added >non-issue :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) Team:Distributed Coordination Meta label for Distributed Coordination team v9.3.0 labels Oct 30, 2025
@DiannaHohensee DiannaHohensee requested a review from ywangd October 30, 2025 19:05
@elasticsearchmachine
Copy link
Collaborator

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

@DiannaHohensee
Copy link
Contributor Author

DiannaHohensee commented Oct 30, 2025

Working through adding NOT_PREFERRED to allocation explain and these refactors help me reason about it better.

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

*/
public boolean cannotRemain() {
checkDecisionState();
return canRemainDecision.type() != Type.YES;
Copy link
Member

Choose a reason for hiding this comment

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

Can we either assert the boolean result here is the opposite to canRemain() or delegate it to canRemain(), i.e. return canRemain() == false? It would be nice to prevent these methods to go out of sync for any reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hesitate because they may not always be opposites: NOT_PREFERRED makes the ideas muddier. But that's a future 'if". I'll go ahead with canRemain() == false since that's how it works now 👍

@DiannaHohensee DiannaHohensee added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Nov 7, 2025
@elasticsearchmachine elasticsearchmachine merged commit 0de0dce into elastic:main Nov 7, 2025
34 checks passed
@DiannaHohensee DiannaHohensee deleted the 2025/10/30/refactor-for-explain branch November 7, 2025 21:48
Kubik42 pushed a commit to Kubik42/elasticsearch that referenced this pull request Nov 10, 2025
Add `MoveDecision#cannotRemain()` to replace the numerous `canRemain()
== false` checks

Rename `Balancer#decideRebalance()` to 
`Balancer#explainRebalanceDecision()`

Rename a `Decision canRemain` variable to `Decision canRemainDecision`
so it doesn't sound like a boolean

Relates ES-12833
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :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.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants