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
Add explain
flag support to the reroute API
#5027
Conversation
clusterStateToSend = newState; | ||
if (request.dryRun) { | ||
return currentState; | ||
if (request.explain()) { |
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.
so it is not possible to get the explain if I also want to reroute ie. actually exectue the operation? I mean we could still make ups of the dryRun flag and get explains if dryRun = false
By specifying the `explain` flag, an explanation for the reason a command can or cannot be executed is returned. No allocation commands are actually performed. Returns a response similar to: { "explanations" : [ { "command" : "cancel", "parameters" : { "index" : "decide", "shard" : 0, "node" : "IvpoKRdtRiGrQ_WKtt4_4w", "allow_primary" : false }, "decisions" : [ { "decider" : "CancelAllocationCommand", "decision" : "YES", "explanation" : "..." } ] }, { "command" : "move", "parameters" : { "index" : "decide", "shard" : 0, "from_node" : "IvpoKRdtRiGrQ_WKtt4_4w", "to_node" : "IvpoKRdtRiGrQ_WKtt4_4w" }, "decisions" : [ { "decider" : "same_shard", "decision" : "NO", "explanation" : "shard cannot be allocated on same node [IvpoKRdtRiGrQ_WKtt4_4w] it already exists on" }, etc ] }] } Closes elastic#2483
@@ -110,6 +128,7 @@ public void readFrom(StreamInput in) throws IOException { | |||
super.readFrom(in); | |||
commands = AllocationCommands.readFrom(in); | |||
dryRun = in.readBoolean(); | |||
explain = in.readBoolean(); |
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 guess we need a version check here sicne we are changing the protocol?
I have a couple of problems with how this at the current stage. Implementation wise the code looks great but I think from my understanding a reroute call with |
Yea, I understand what you're saying. I will work on removing the RoutingAllocation.Result from the cluster state, which should allow me to return the explain results every time, even while executing the commands. |
@s1monw okay, I have made a lot of changes, please take another look
|
@@ -110,6 +129,11 @@ public void readFrom(StreamInput in) throws IOException { | |||
super.readFrom(in); | |||
commands = AllocationCommands.readFrom(in); | |||
dryRun = in.readBoolean(); | |||
if (in.getVersion().onOrAfter(Version.V_2_0_0)) { |
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 think this can be V_1_1_0
?
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.
Yea, I wasn't sure where this was going to end up, thought it might be 2.0-only since it includes cluster state changes, but I can definitely change that.
I like this much better I left some comments I think we are close... |
@s1monw updated again with the changes you mentioned. |
LGTM |
Merged to 1.x and master |
By specifying the
explain
flag, an explanation for the reason acommand can or cannot be executed is returned. No allocation commands
are actually performed.
Returns a response similar to:
An example of the full output is in #2483
Closes #5169