Skip to content

Commit

Permalink
Create is now working
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Sep 14, 2023
1 parent 152d842 commit 255f4e1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
3 changes: 3 additions & 0 deletions go/cmd/vtctldclient/command/vreplication/vdiff/vdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func commandVDiffCreate(cmd *cobra.Command, args []string) error {
resp, err := common.GetClient().VDiffCreate(common.GetCommandCtx(), &vtctldatapb.VDiffCreateRequest{
Workflow: common.BaseOptions.Workflow,
TargetKeyspace: common.BaseOptions.TargetKeyspace,
Uuid: vDiffCreateOptions.UUID.String(),
SourceCells: vDiffCreateOptions.SourceCells,
TargetCells: vDiffCreateOptions.TargetCells,
TabletTypes: vDiffCreateOptions.TabletTypes,
Expand Down Expand Up @@ -164,6 +165,8 @@ func commandVDiffCreate(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
} else {
data = []byte(fmt.Sprintf("VDiff %s scheduled on target shards, use show to view progress", resp.Uuid))
}

fmt.Printf("%s\n", data)
Expand Down
4 changes: 4 additions & 0 deletions go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4697,6 +4697,10 @@ func (s *VtctldServer) VDiffCreate(ctx context.Context, req *vtctldatapb.VDiffCr

span.Annotate("keyspace", req.TargetKeyspace)
span.Annotate("workflow", req.Workflow)
span.Annotate("uuid", req.Uuid)
span.Annotate("source_cells", req.SourceCells)
span.Annotate("target_cells", req.TargetCells)
span.Annotate("tablet_types", req.TabletTypes)

resp, err = s.ws.VDiffCreate(ctx, req)
return resp, err
Expand Down
24 changes: 8 additions & 16 deletions go/vt/vtctl/workflow/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ type sequenceMetadata struct {

type VDiffOutput struct {
mu sync.Mutex
Request *tabletmanagerdata.VDiffRequest
Responses map[string]*tabletmanagerdata.VDiffResponse
Err error
request *tabletmanagerdata.VDiffRequest
responses map[string]*tabletmanagerdata.VDiffResponse
err error
}

const (
Expand Down Expand Up @@ -1349,11 +1349,6 @@ func (s *Server) VDiffCreate(ctx context.Context, req *vtctldatapb.VDiffCreateRe
Options: options,
VdiffUuid: req.Uuid,
}
output := &VDiffOutput{
Request: tabletreq,
Responses: make(map[string]*tabletmanagerdata.VDiffResponse),
Err: nil,
}

ts, err := s.buildTrafficSwitcher(ctx, req.TargetKeyspace, req.Workflow)
if err != nil {
Expand All @@ -1364,16 +1359,13 @@ func (s *Server) VDiffCreate(ctx context.Context, req *vtctldatapb.VDiffCreateRe
req.TargetKeyspace, req.Workflow)
}

output.Err = ts.ForAllTargets(func(target *MigrationTarget) error {
resp, err := s.tmc.VDiff(ctx, target.GetPrimary().Tablet, tabletreq)
output.mu.Lock()
defer output.mu.Unlock()
output.Responses[target.GetShard().ShardName()] = resp
err = ts.ForAllTargets(func(target *MigrationTarget) error {
_, err := s.tmc.VDiff(ctx, target.GetPrimary().Tablet, tabletreq)
return err
})
if output.Err != nil {
log.Errorf("Error executing action %s: %v", vdiff.CreateAction, output.Err)
return nil, output.Err
if err != nil {
log.Errorf("Error executing action %s: %v", vdiff.CreateAction, err)
return nil, err
}

return &vtctldatapb.VDiffCreateResponse{
Expand Down

0 comments on commit 255f4e1

Please sign in to comment.