Skip to content

Commit

Permalink
Workflow Delete: remove workflow before artifacts
Browse files Browse the repository at this point in the history
Otherwise the cancel/delete and cleanup work can fail.

Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed May 20, 2024
1 parent 9911880 commit 9fd6793
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions go/vt/vtctl/workflow/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1970,14 +1970,6 @@ func (s *Server) WorkflowDelete(ctx context.Context, req *vtctldatapb.WorkflowDe
span.Annotate("keep_routing_rules", req.KeepRoutingRules)
span.Annotate("shards", req.Shards)

// Cleanup related data and artifacts.
if _, err := s.DropTargets(ctx, req.Keyspace, req.Workflow, req.KeepData, req.KeepRoutingRules, false); err != nil {
if topo.IsErrType(err, topo.NoNode) {
return nil, vterrors.Wrapf(err, "%s keyspace does not exist", req.Keyspace)
}
return nil, err
}

deleteReq := &tabletmanagerdatapb.DeleteVReplicationWorkflowRequest{
Workflow: req.Workflow,
}
Expand All @@ -2002,6 +1994,14 @@ func (s *Server) WorkflowDelete(ctx context.Context, req *vtctldatapb.WorkflowDe
return nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "the %s workflow does not exist in the %s keyspace", req.Workflow, req.Keyspace)
}

// Cleanup related data and artifacts.
if _, err := s.DropTargets(ctx, req.Keyspace, req.Workflow, req.KeepData, req.KeepRoutingRules, false); err != nil {
if topo.IsErrType(err, topo.NoNode) {
return nil, vterrors.Wrapf(err, "%s keyspace does not exist", req.Keyspace)
}
return nil, err
}

response := &vtctldatapb.WorkflowDeleteResponse{}
response.Summary = fmt.Sprintf("Successfully cancelled the %s workflow in the %s keyspace", req.Workflow, req.Keyspace)
details := make([]*vtctldatapb.WorkflowDeleteResponse_TabletInfo, 0, len(res))
Expand Down

0 comments on commit 9fd6793

Please sign in to comment.