Add reroute command for shard allocation#5
Open
szabolcsf wants to merge 1 commit intocyborgize:masterfrom
Open
Add reroute command for shard allocation#5szabolcsf wants to merge 1 commit intocyborgize:masterfrom
szabolcsf wants to merge 1 commit intocyborgize:masterfrom
Conversation
- Add new 'reroute' command to support manual shard allocation - Support for allocating replica shards (safe operation) - Support for allocating empty primary shards with data loss confirmation - Interactive confirmation dialog for dangerous primary shard operations - Additional options: --explain and --retry-failed - Proper ATD type definitions for reroute operations - JSON serialization and HTTP request handling - Comprehensive help documentation with examples - Updated README.md with anonymized usage examples Usage: es reroute <cluster> -r <index>:<shard>:<node> # allocate replica es reroute <cluster> -p <index>:<shard>:<node> # allocate empty primary The command follows the same patterns as existing elasticsearch-cli commands and integrates seamlessly with the existing codebase.
7d87d9f to
0228195
Compare
ahrrv
reviewed
Aug 12, 2025
Comment on lines
+2086
to
+2087
| `P "Use -r to allocate replica shards (safe operation)."; | ||
| `P "Use -p to allocate empty primary shards (WARNING: causes data loss!)."; |
There was a problem hiding this comment.
I think these should not be needed as it just repeats the args' documentation.
ahrrv
reviewed
Aug 12, 2025
Comment on lines
+2049
to
+2051
| let parse_allocation spec = | ||
| match String.split_on_char ':' spec with | ||
| | [index; shard_str; node] -> |
There was a problem hiding this comment.
for this kind of options, need to create a converter using Arg.conv (I think there are also a few ready-made converters under Arg.Conv).
ahrrv
reviewed
Aug 12, 2025
| | _ -> None | ||
| in | ||
| let replica_actions = | ||
| List.filter_map (fun spec -> |
There was a problem hiding this comment.
filter_map and the only valid return is Some ...
LLM is drunk
ahrrv
reviewed
Aug 12, 2025
| move = None; cancel = None; } in | ||
| Lwt.return (Some cmd) | ||
| else | ||
| let%lwt () = Lwt_io.eprintl "Operation cancelled." in |
There was a problem hiding this comment.
I think this should fail the whole operation. That is, all-or-nothing semantics.
ahrrv
reviewed
Aug 12, 2025
Comment on lines
+241
to
+242
| ?move : move_shard option; | ||
| ?cancel : cancel_shard option; |
There was a problem hiding this comment.
These are in ATD but not available as commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Usage:
es reroute -r :: # allocate replica es reroute -p :: # allocate empty primary
The command follows the same patterns as existing elasticsearch-cli commands and integrates seamlessly with the existing codebase.