Skip to content

Commit

Permalink
[vtctldclient] Add GetShardReplication (vitessio#15389)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Mason <[email protected]>
  • Loading branch information
Andrew Mason authored Feb 29, 2024
1 parent 15f5886 commit 45ae25e
Show file tree
Hide file tree
Showing 14 changed files with 4,924 additions and 3,151 deletions.
39 changes: 39 additions & 0 deletions go/cmd/vtctldclient/command/shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ that shard.`,
Args: cobra.ExactArgs(1),
RunE: commandGetShard,
}
// GetShardReplication makes a GetShardReplication gRPC request to a vtctld.
GetShardReplication = &cobra.Command{
Use: "GetShardReplication <keyspace/shard> [cell1 [cell2...]]",
Short: "Returns information about the replication relationships for a shard in the given cell(s).",
DisableFlagsInUseLine: true,
Args: cobra.MinimumNArgs(1),
RunE: commandGetShardReplication,
}
// RemoveShardCell makes a RemoveShardCell gRPC request to a vtctld.
RemoveShardCell = &cobra.Command{
Use: "RemoveShardCell [--force|-f] [--recursive|-r] <keyspace/shard> <cell>",
Expand Down Expand Up @@ -286,6 +294,36 @@ func commandGetShard(cmd *cobra.Command, args []string) error {
return nil
}

func commandGetShardReplication(cmd *cobra.Command, args []string) error {
keyspace, shard, err := topoproto.ParseKeyspaceShard(cmd.Flags().Arg(0))
if err != nil {
return err
}

cells := cmd.Flags().Args()[1:]

cli.FinishedParsing(cmd)

resp, err := client.GetShardReplication(commandCtx, &vtctldatapb.GetShardReplicationRequest{
Keyspace: keyspace,
Shard: shard,
Cells: cells,
})
if err != nil {
return err
}

data, err := cli.MarshalJSON(resp)
if err != nil {
return err
}

fmt.Printf("%s\n", data)

return nil

}

var removeShardCellOptions = struct {
Force bool
Recursive bool
Expand Down Expand Up @@ -624,6 +662,7 @@ func init() {
Root.AddCommand(DeleteShards)

Root.AddCommand(GetShard)
Root.AddCommand(GetShardReplication)
Root.AddCommand(GenerateShardRanges)

RemoveShardCell.Flags().BoolVarP(&removeShardCellOptions.Force, "force", "f", false, "Proceed even if the cell's topology server cannot be reached. The assumption is that you turned down the entire cell, and just need to update the global topo data.")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vtctldclient.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Available Commands:
GetRoutingRules Displays the VSchema routing rules.
GetSchema Displays the full schema for a tablet, optionally restricted to the specified tables/views.
GetShard Returns information about a shard in the topology.
GetShardReplication Returns information about the replication relationships for a shard in the given cell(s).
GetShardRoutingRules Displays the currently active shard routing rules as a JSON document.
GetSrvKeyspaceNames Outputs a JSON mapping of cell=>keyspace names served in that cell. Omit to query all cells.
GetSrvKeyspaces Returns the SrvKeyspaces for the given keyspace in one or more cells.
Expand Down
Loading

0 comments on commit 45ae25e

Please sign in to comment.