-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Make sure explanation is populated when .not_preferred logging is turned on #138325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure explanation is populated when .not_preferred logging is turned on #138325
Conversation
|
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
DiannaHohensee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Left some superficial suggestions.
...ain/java/org/elasticsearch/cluster/routing/allocation/allocator/BalancedShardsAllocator.java
Outdated
Show resolved
Hide resolved
| if (notPreferredLogger.isDebugEnabled()) { | ||
| allocation.setDebugMode(RoutingAllocation.DebugMode.EXCLUDE_YES_DECISIONS); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (notPreferredLogger.isDebugEnabled()) { | |
| allocation.setDebugMode(RoutingAllocation.DebugMode.EXCLUDE_YES_DECISIONS); | |
| } | |
| allocation.setDebugMode(notPreferredLogger.isDebugEnabled() ? RoutingAllocation.DebugMode.EXCLUDE_YES_DECISIONS : oldDebugMode); | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left this one because I don't think either form is significantly more or less readable, and it seems weird to set the value if it's not being changed.
| * If a shard has moved we need to re-run the decision to check that it's still valid. If {@link #notPreferredLogger} is | ||
| * set to debug, we re-run the decision with explain turned on so we can populate the explanation in our log message | ||
| * | ||
| * @param index The index of the shard | ||
| * @param storedShardMovement The existing shard movement decision | ||
| * @param shardMoved True if a shard moved in this balancing round, false otherwise | ||
| * @return The move decision to act on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found
"If a shard has moved we need to re-run the decision to check that it's still valid."
to be difficult to follow. Could it be replaced with something like
"If any shards in the cluster have been relocated since the stored shard movement was calculated, the move decision must be re-run to ensure it is still allowed."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved(?) in c9a8751
...ain/java/org/elasticsearch/cluster/routing/allocation/allocator/BalancedShardsAllocator.java
Outdated
Show resolved
Hide resolved
…ion/allocator/BalancedShardsAllocator.java Co-authored-by: Dianna Hohensee <artemisapple@gmail.com>
My previous attempt at logging more info on
NOT_PREFERREDdecisions that are acted on missed that we discard the explanation unlessdebugDecision()is turned on.This PR means we re-run
decideMove()withdebugDecision()turned on when the.not_preferredlogger is turned on and we're about to act on aNOT_PREFERREDdecision. I think this will be generally useful as we roll out more deciders capable of returningNOT_PREFERRED.