Skip to content

Commit

Permalink
Add traffic status to workflow status output
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Oct 14, 2023
1 parent 314ebcf commit 74f056b
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 128 deletions.
6 changes: 5 additions & 1 deletion go/cmd/vtctldclient/command/vreplication/common/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func GetStatusCommand(opts *SubCommandsOpts) *cobra.Command {
}

func commandStatus(cmd *cobra.Command, args []string) error {
format, err := GetOutputFormat(cmd)
if err != nil {
return err
}
cli.FinishedParsing(cmd)

req := &vtctldatapb.WorkflowStatusRequest{
Expand All @@ -51,7 +55,7 @@ func commandStatus(cmd *cobra.Command, args []string) error {
return err
}

if err = OutputStatusResponse(resp, "json"); err != nil {
if err = OutputStatusResponse(resp, format); err != nil {
return err
}

Expand Down
4 changes: 3 additions & 1 deletion go/cmd/vtctldclient/command/vreplication/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ func OutputStatusResponse(resp *vtctldatapb.WorkflowStatusResponse, format strin
shardstream.Id, BaseOptions.TargetKeyspace, tablet, shardstream.Status, shardstream.Info))
}
}
tout.WriteString("\nTraffic:\n")
tout.WriteString(resp.Traffic)
output = tout.Bytes()
}
fmt.Printf("%s\n", output)
fmt.Println(string(output))
return nil
}

Expand Down
254 changes: 132 additions & 122 deletions go/vt/proto/vtctldata/vtctldata.pb.go

Large diffs are not rendered by default.

47 changes: 46 additions & 1 deletion go/vt/proto/vtctldata/vtctldata_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/vt/vtctl/workflow/materializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func TestMoveTablesDDLFlag(t *testing.T) {
require.NoError(t, err)
sourceShard, err := env.topoServ.GetShardNames(ctx, ms.SourceKeyspace)
require.NoError(t, err)
want := fmt.Sprintf("shard_streams:{key:\"%s/%s\" value:{streams:{id:1 tablet:{cell:\"%s\" uid:200} source_shard:\"%s/%s\" position:\"9d10e6ec-07a0-11ee-ae73-8e53f4cf3083:1-97\" status:\"running\" info:\"VStream Lag: 0s\"}}}",
want := fmt.Sprintf("shard_streams:{key:\"%s/%s\" value:{streams:{id:1 tablet:{cell:\"%s\" uid:200} source_shard:\"%s/%s\" position:\"9d10e6ec-07a0-11ee-ae73-8e53f4cf3083:1-97\" status:\"running\" info:\"VStream Lag: 0s\"}}} traffic:\"Reads Not Switched. Writes Not Switched\"",
ms.TargetKeyspace, targetShard[0], env.cell, ms.SourceKeyspace, sourceShard[0])

res, err := env.ws.MoveTablesCreate(ctx, &vtctldatapb.MoveTablesCreateRequest{
Expand Down Expand Up @@ -568,7 +568,7 @@ func TestMoveTablesNoRoutingRules(t *testing.T) {
require.NoError(t, err)
sourceShard, err := env.topoServ.GetShardNames(ctx, ms.SourceKeyspace)
require.NoError(t, err)
want := fmt.Sprintf("shard_streams:{key:\"%s/%s\" value:{streams:{id:1 tablet:{cell:\"%s\" uid:200} source_shard:\"%s/%s\" position:\"9d10e6ec-07a0-11ee-ae73-8e53f4cf3083:1-97\" status:\"running\" info:\"VStream Lag: 0s\"}}}",
want := fmt.Sprintf("shard_streams:{key:\"%s/%s\" value:{streams:{id:1 tablet:{cell:\"%s\" uid:200} source_shard:\"%s/%s\" position:\"9d10e6ec-07a0-11ee-ae73-8e53f4cf3083:1-97\" status:\"running\" info:\"VStream Lag: 0s\"}}} traffic:\"Reads Not Switched. Writes Not Switched\"",
ms.TargetKeyspace, targetShard[0], env.cell, ms.SourceKeyspace, sourceShard[0])

res, err := env.ws.MoveTablesCreate(ctx, &vtctldatapb.MoveTablesCreateRequest{
Expand Down
4 changes: 3 additions & 1 deletion go/vt/vtctl/workflow/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1884,7 +1884,9 @@ func (s *Server) WorkflowStatus(ctx context.Context, req *vtctldatapb.WorkflowSt
if err != nil {
return nil, err
}
resp := &vtctldatapb.WorkflowStatusResponse{}
resp := &vtctldatapb.WorkflowStatusResponse{
Traffic: state.String(),
}
if copyProgress != nil {
resp.TableCopyState = make(map[string]*vtctldatapb.WorkflowStatusResponse_TableCopyState, len(*copyProgress))
// We sort the tables for intuitive and consistent output.
Expand Down
1 change: 1 addition & 0 deletions proto/vtctldata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1817,6 +1817,7 @@ message WorkflowStatusResponse {
// The key is keyspace/shard.
map<string, TableCopyState> table_copy_state = 1;
map<string, ShardStreams> shard_streams = 2;
string traffic = 3;
}

message WorkflowSwitchTrafficRequest {
Expand Down
6 changes: 6 additions & 0 deletions web/vtadmin/src/proto/vtadmin.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions web/vtadmin/src/proto/vtadmin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 74f056b

Please sign in to comment.