Skip to content

Commit

Permalink
Add MoveTables cancel and complete flags back
Browse files Browse the repository at this point in the history
They were accidentally removed in the refactor
done in:
vitessio#13792

Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Oct 5, 2023
1 parent c50f781 commit bab9cff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
6 changes: 3 additions & 3 deletions go/cmd/vtctldclient/command/vreplication/common/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"
)

var cancelOptions = struct {
var CancelOptions = struct {
KeepData bool
KeepRoutingRules bool
}{}
Expand Down Expand Up @@ -56,8 +56,8 @@ func commandCancel(cmd *cobra.Command, args []string) error {
req := &vtctldatapb.WorkflowDeleteRequest{
Keyspace: BaseOptions.TargetKeyspace,
Workflow: BaseOptions.Workflow,
KeepData: cancelOptions.KeepData,
KeepRoutingRules: cancelOptions.KeepRoutingRules,
KeepData: CancelOptions.KeepData,
KeepRoutingRules: CancelOptions.KeepRoutingRules,
}
resp, err := GetClient().WorkflowDelete(GetCommandCtx(), req)
if err != nil {
Expand Down
14 changes: 0 additions & 14 deletions go/cmd/vtctldclient/command/vreplication/movetables/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,3 @@ func commandMoveTablesCreate(cmd *cobra.Command, args []string) error {
}
return nil
}

func registerCreateCommand(root *cobra.Command) {
common.AddCommonCreateFlags(moveTablesCreate)
moveTablesCreate.PersistentFlags().StringVar(&moveTablesCreateOptions.SourceKeyspace, "source-keyspace", "", "Keyspace where the tables are being moved from.")
moveTablesCreate.MarkPersistentFlagRequired("source-keyspace")
moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.SourceShards, "source-shards", nil, "Source shards to copy data from when performing a partial moveTables (experimental).")
moveTablesCreate.Flags().StringVar(&moveTablesCreateOptions.SourceTimeZone, "source-time-zone", "", "Specifying this causes any DATETIME fields to be converted from the given time zone into UTC.")
moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.AllTables, "all-tables", false, "Copy all tables from the source.")
moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.IncludeTables, "tables", nil, "Source tables to copy.")
moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.ExcludeTables, "exclude-tables", nil, "Source tables to exclude from copying.")
moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.NoRoutingRules, "no-routing-rules", false, "(Advanced) Do not create routing rules while creating the workflow. See the reference documentation for limitations if you use this flag.")
moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.AtomicCopy, "atomic-copy", false, "(EXPERIMENTAL) A single copy phase is run for all tables from the source. Use this, for example, if your source keyspace has tables which use foreign key constraints.")
moveTables.AddCommand(moveTablesCreate)
}
26 changes: 23 additions & 3 deletions go/cmd/vtctldclient/command/vreplication/movetables/movetables.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@ func registerMoveTablesCommands(root *cobra.Command) {
common.AddCommonFlags(moveTables)
root.AddCommand(moveTables)

registerCreateCommand(moveTables)
common.AddCommonCreateFlags(moveTablesCreate)
moveTablesCreate.PersistentFlags().StringVar(&moveTablesCreateOptions.SourceKeyspace, "source-keyspace", "", "Keyspace where the tables are being moved from.")
moveTablesCreate.MarkPersistentFlagRequired("source-keyspace")
moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.SourceShards, "source-shards", nil, "Source shards to copy data from when performing a partial moveTables (experimental).")
moveTablesCreate.Flags().StringVar(&moveTablesCreateOptions.SourceTimeZone, "source-time-zone", "", "Specifying this causes any DATETIME fields to be converted from the given time zone into UTC.")
moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.AllTables, "all-tables", false, "Copy all tables from the source.")
moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.IncludeTables, "tables", nil, "Source tables to copy.")
moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.ExcludeTables, "exclude-tables", nil, "Source tables to exclude from copying.")
moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.NoRoutingRules, "no-routing-rules", false, "(Advanced) Do not create routing rules while creating the workflow. See the reference documentation for limitations if you use this flag.")
moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.AtomicCopy, "atomic-copy", false, "(EXPERIMENTAL) A single copy phase is run for all tables from the source. Use this, for example, if your source keyspace has tables which use foreign key constraints.")
moveTables.AddCommand(moveTablesCreate)

opts := &common.SubCommandsOpts{
SubCommand: "MoveTables",
Workflow: "commerce2customer",
Expand All @@ -56,8 +67,17 @@ func registerMoveTablesCommands(root *cobra.Command) {
common.AddCommonSwitchTrafficFlags(reverseTrafficCommand, false)
moveTables.AddCommand(reverseTrafficCommand)

moveTables.AddCommand(common.GetCompleteCommand(opts))
moveTables.AddCommand(common.GetCancelCommand(opts))
complete := common.GetCompleteCommand(opts)
complete.Flags().BoolVar(&common.CompleteOptions.KeepData, "keep-data", false, "Keep the original source table data that was copied by the MoveTables workflow")
complete.Flags().BoolVar(&common.CompleteOptions.KeepRoutingRules, "keep-routing-rules", false, "Keep the routing rules in place that direct table traffic from the source keyspace to the target keyspace of the MoveTables workflow")
complete.Flags().BoolVar(&common.CompleteOptions.RenameTables, "rename-tables", false, "Keep the original source table data that was copied by the MoveTables workflow, but rename each table to '_<tablename>_old'")
complete.Flags().BoolVar(&common.CompleteOptions.DryRun, "dry-run", false, "Print the actions that would be taken and report any known errors that would have occurred")
moveTables.AddCommand(complete)

cancel := common.GetCancelCommand(opts)
cancel.Flags().BoolVar(&common.CancelOptions.KeepData, "keep-data", false, "Keep the partially copied table data from the MoveTables workflow in the target keyspace")
cancel.Flags().BoolVar(&common.CancelOptions.KeepRoutingRules, "keep-routing-rules", false, "Keep the routing rules created for the MoveTables workflow")
moveTables.AddCommand(cancel)
}

func init() {
Expand Down

0 comments on commit bab9cff

Please sign in to comment.