Skip to content
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

[release-19.0] [vtctldclient] Add GetShardReplication (#15389) #15390

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
return nil
}

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

Check warning on line 300 in go/cmd/vtctldclient/command/shards.go

View check run for this annotation

Codecov / codecov/patch

go/cmd/vtctldclient/command/shards.go#L297-L300

Added lines #L297 - L300 were not covered by tests
}

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

Check warning on line 303 in go/cmd/vtctldclient/command/shards.go

View check run for this annotation

Codecov / codecov/patch

go/cmd/vtctldclient/command/shards.go#L303

Added line #L303 was not covered by tests

cli.FinishedParsing(cmd)

Check warning on line 305 in go/cmd/vtctldclient/command/shards.go

View check run for this annotation

Codecov / codecov/patch

go/cmd/vtctldclient/command/shards.go#L305

Added line #L305 was not covered by tests

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

Check warning on line 313 in go/cmd/vtctldclient/command/shards.go

View check run for this annotation

Codecov / codecov/patch

go/cmd/vtctldclient/command/shards.go#L307-L313

Added lines #L307 - L313 were not covered by tests
}

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

Check warning on line 318 in go/cmd/vtctldclient/command/shards.go

View check run for this annotation

Codecov / codecov/patch

go/cmd/vtctldclient/command/shards.go#L316-L318

Added lines #L316 - L318 were not covered by tests
}

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

Check warning on line 321 in go/cmd/vtctldclient/command/shards.go

View check run for this annotation

Codecov / codecov/patch

go/cmd/vtctldclient/command/shards.go#L321

Added line #L321 was not covered by tests

return nil

Check warning on line 323 in go/cmd/vtctldclient/command/shards.go

View check run for this annotation

Codecov / codecov/patch

go/cmd/vtctldclient/command/shards.go#L323

Added line #L323 was not covered by tests

}

var removeShardCellOptions = struct {
Force bool
Recursive bool
Expand Down Expand Up @@ -624,6 +662,7 @@
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
Loading