Skip to content

Commit

Permalink
Response improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed May 3, 2023
1 parent 16fe219 commit 0763cf1
Show file tree
Hide file tree
Showing 7 changed files with 1,437 additions and 802 deletions.
1,604 changes: 841 additions & 763 deletions go/vt/proto/vtctldata/vtctldata.pb.go

Large diffs are not rendered by default.

207 changes: 193 additions & 14 deletions 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.

22 changes: 16 additions & 6 deletions go/vt/vtctl/workflow/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,18 @@ func (s *Server) MoveTablesCreate(ctx context.Context, req *vtctldatapb.MoveTabl
return nil, fmt.Errorf("the %s workflow does not exist in the %s keyspace", req.Workflow, req.TargetKeyspace)
}

if req.AutoStart {
err = mz.startStreams(ctx)
response := &vtctldatapb.MoveTablesCreateResponse{}
response.Summary = fmt.Sprintf("Successfully created the %s MoveTables workflow on (%d) target primary tablets in the %s keyspace", req.Workflow, len(res), req.TargetKeyspace)
details := make([]*vtctldatapb.MoveTablesCreateResponse_TabletInfo, 0, len(res))
for tinfo, tres := range res {
result := &vtctldatapb.MoveTablesCreateResponse_TabletInfo{
Tablet: fmt.Sprintf("%s-%d (%s/%s)", tinfo.Alias.Cell, tinfo.Alias.Uid, tinfo.Keyspace, tinfo.Shard),
Created: tres.RowsAffected > 0, // Can be more than one with shard merges
}
details = append(details, result)
}

return nil, err
response.Details = details
return response, nil
}

// WorkflowCreate is part of the vtctlservicepb.VtctldServer interface.
Expand All @@ -996,9 +1003,12 @@ func (s *Server) WorkflowDelete(ctx context.Context, req *vtctldatapb.WorkflowDe
span.Annotate("keyspace", req.Keyspace)
span.Annotate("workflow", req.Workflow)

deleteReq := &tabletmanagerdatapb.DeleteVRWorkflowRequest{
Workflow: req.Workflow,
}
vx := vexec.NewVExec(req.Keyspace, req.Workflow, s.ts, s.tmc)
callback := func(ctx context.Context, tablet *topo.TabletInfo) (*querypb.QueryResult, error) {
res, err := s.tmc.DeleteVRWorkflow(ctx, tablet.Tablet, nil)
res, err := s.tmc.DeleteVRWorkflow(ctx, tablet.Tablet, deleteReq)
if err != nil {
return nil, err
}
Expand All @@ -1017,7 +1027,7 @@ func (s *Server) WorkflowDelete(ctx context.Context, req *vtctldatapb.WorkflowDe
}

response := &vtctldatapb.WorkflowDeleteResponse{}
response.Summary = fmt.Sprintf("Successfully updated the %s workflow on (%d) target primary tablets in the %s keyspace", req.Workflow, len(res), req.Keyspace)
response.Summary = fmt.Sprintf("Successfully deleted the %s workflow on (%d) target primary tablets in the %s keyspace", req.Workflow, len(res), req.Keyspace)
details := make([]*vtctldatapb.WorkflowDeleteResponse_TabletInfo, 0, len(res))
for tinfo, tres := range res {
result := &vtctldatapb.WorkflowDeleteResponse_TabletInfo{
Expand Down
8 changes: 8 additions & 0 deletions go/vt/vttablet/faketmclient/fake_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ type FakeTabletManagerClient struct {
tmc tmclient.TabletManagerClient
}

func (client *FakeTabletManagerClient) CreateVRWorkflow(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.CreateVRWorkflowRequest) (*tabletmanagerdatapb.CreateVRWorkflowResponse, error) {
return nil, nil
}

func (client *FakeTabletManagerClient) DeleteVRWorkflow(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.DeleteVRWorkflowRequest) (*tabletmanagerdatapb.DeleteVRWorkflowResponse, error) {
return nil, nil
}

func (client *FakeTabletManagerClient) UpdateVRWorkflow(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.UpdateVRWorkflowRequest) (*tabletmanagerdatapb.UpdateVRWorkflowResponse, error) {
return nil, nil
}
Expand Down
8 changes: 7 additions & 1 deletion proto/vtctldata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,14 @@ message MoveTablesCreateRequest {
}

message MoveTablesCreateResponse {
message TabletInfo {
string tablet = 1;
// The value is based on the query result's RowsAffected
// being 0 or not.
bool created = 2;
}
string summary = 1;
string details = 2;
repeated TabletInfo details = 2;
}

message PingTabletRequest {
Expand Down
Loading

0 comments on commit 0763cf1

Please sign in to comment.