Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated vtctl commands #15228

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go/test/endtoend/cluster/vtctl_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (vtctl *VtctlProcess) ExecuteCommandWithOutput(args ...string) (result stri
vtctl.Binary,
filterDoubleDashArgs(args, vtctl.VtctlMajorVersion)...,
)
log.Info(fmt.Sprintf("Executing vtctlclient with arguments %v", strings.Join(tmpProcess.Args, " ")))
log.Info(fmt.Sprintf("Executing vtctl with arguments %v", strings.Join(tmpProcess.Args, " ")))
resultByte, err := tmpProcess.CombinedOutput()
return filterResultForWarning(filterResultWhenRunsForCoverage(string(resultByte))), err
}
Expand All @@ -107,7 +107,7 @@ func (vtctl *VtctlProcess) ExecuteCommand(args ...string) (err error) {
vtctl.Binary,
filterDoubleDashArgs(args, vtctl.VtctlMajorVersion)...,
)
log.Info(fmt.Sprintf("Executing vtctlclient with arguments %v", strings.Join(tmpProcess.Args, " ")))
log.Info(fmt.Sprintf("Executing vtctl with arguments %v", strings.Join(tmpProcess.Args, " ")))
return tmpProcess.Run()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestSecureTransport(t *testing.T) {
vtctlClientTmArgs := append(vtctlClientArgs, tmclientExtraArgs("vttablet-client-1")...)

// Reparenting
vtctlClientArgs = append(vtctlClientTmArgs, "InitShardPrimary", "--", "--force", "test_keyspace/0", primaryTablet.Alias)
vtctlClientArgs = append(vtctlClientTmArgs, "PlannedReparentShard", "--", "test_keyspace/0", primaryTablet.Alias)
err = clusterInstance.VtctlProcess.ExecuteCommand(vtctlClientArgs...)
require.NoError(t, err)

Expand Down
32 changes: 0 additions & 32 deletions go/vt/vtctl/reparent.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ func init() {
params: "<tablet alias>",
help: "Reparent a tablet to the current primary in the shard. This only works if the current replication position matches the last known reparent action.",
})
addCommand("Shards", command{
name: "InitShardPrimary",
method: commandInitShardPrimary,
params: "[--force] [--wait_replicas_timeout=<duration>] <keyspace/shard> <tablet alias>",
help: "Sets the initial primary for a shard. Will make all other tablets in the shard replicas of the provided tablet. WARNING: this could cause data loss on an already replicating shard. PlannedReparentShard or EmergencyReparentShard should be used instead.",
deprecated: true,
deprecatedBy: "PlannedReparentShard",
})
addCommand("Shards", command{
name: "PlannedReparentShard",
method: commandPlannedReparentShard,
Expand Down Expand Up @@ -85,30 +77,6 @@ func commandReparentTablet(ctx context.Context, wr *wrangler.Wrangler, subFlags
return wr.ReparentTablet(ctx, tabletAlias)
}

func commandInitShardPrimary(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
if mysqlctl.DisableActiveReparents {
return fmt.Errorf("active reparent commands disabled (unset the --disable_active_reparents flag to enable)")
}

force := subFlags.Bool("force", false, "will force the reparent even if the provided tablet is not writable or the shard primary")
waitReplicasTimeout := subFlags.Duration("wait_replicas_timeout", topo.RemoteOperationTimeout, "time to wait for replicas to catch up in reparenting")
if err := subFlags.Parse(args); err != nil {
return err
}
if subFlags.NArg() != 2 {
return fmt.Errorf("action InitShardPrimary requires <keyspace/shard> <tablet alias>")
}
keyspace, shard, err := topoproto.ParseKeyspaceShard(subFlags.Arg(0))
if err != nil {
return err
}
tabletAlias, err := topoproto.ParseTabletAlias(subFlags.Arg(1))
if err != nil {
return err
}
return wr.InitShardPrimary(ctx, keyspace, shard, tabletAlias, *force, *waitReplicasTimeout)
}

func commandPlannedReparentShard(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
if mysqlctl.DisableActiveReparents {
return fmt.Errorf("active reparent commands disabled (unset the --disable_active_reparents flag to enable)")
Expand Down
153 changes: 0 additions & 153 deletions go/vt/vtctl/vtctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ import (
"vitess.io/vitess/go/mysql/collations"

"vitess.io/vitess/go/cmd/vtctldclient/cli"
"vitess.io/vitess/go/flagutil"
"vitess.io/vitess/go/json2"
"vitess.io/vitess/go/protoutil"
"vitess.io/vitess/go/sqltypes"
Expand Down Expand Up @@ -169,26 +168,12 @@ var commandsMutex sync.Mutex
var commands = []commandGroup{
{
"Tablets", []command{
{
name: "InitTablet",
method: commandInitTablet,
params: "[--allow_update] [--allow_different_shard] [--allow_master_override] [--parent] [--db_name_override=<db name>] [--hostname=<hostname>] [--mysql_port=<port>] [--port=<port>] [--grpc_port=<port>] [--tags=tag1:value1,tag2:value2] --keyspace=<keyspace> --shard=<shard> <tablet alias> <tablet type>",
help: "Initializes a tablet in the topology.",
deprecated: true,
},
{
name: "GetTablet",
method: commandGetTablet,
params: "<tablet alias>",
help: "Outputs a JSON structure that contains information about the Tablet.",
},
{
name: "UpdateTabletAddrs",
method: commandUpdateTabletAddrs,
params: "[--hostname <hostname>] [--ip-addr <ip addr>] [--mysql-port <mysql port>] [--vt-port <vt port>] [--grpc-port <grpc port>] <tablet alias> ",
help: "Updates the IP address and port numbers of a tablet.",
deprecated: true,
},
{
name: "DeleteTablet",
method: commandDeleteTablet,
Expand Down Expand Up @@ -276,14 +261,6 @@ var commands = []commandGroup{
params: "[--max_rows=10000] [--disable_binlogs] [--json] <tablet alias> <sql command>",
help: "Runs the given SQL command as a DBA on the remote tablet.",
},
{
name: "VReplicationExec",
method: commandVReplicationExec,
params: "[--json] <tablet alias> <sql command>",
help: "Runs the given VReplication command on the remote tablet.",
deprecated: true,
deprecatedBy: "Workflow -- <keyspace.workflow> <action>",
},
},
},
{
Expand Down Expand Up @@ -909,62 +886,6 @@ func parseTabletType(param string, types []topodatapb.TabletType) (topodatapb.Ta
return tabletType, nil
}

func commandInitTablet(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
dbNameOverride := subFlags.String("db_name_override", "", "Overrides the name of the database that the vttablet uses")
allowUpdate := subFlags.Bool("allow_update", false, "Use this flag to force initialization if a tablet with the same name already exists. Use with caution.")
allowPrimaryOverride := subFlags.Bool("allow_master_override", false, "Use this flag to force initialization if a tablet is created as primary, and a primary for the keyspace/shard already exists. Use with caution.")
createShardAndKeyspace := subFlags.Bool("parent", false, "Creates the parent shard and keyspace if they don't yet exist")
hostname := subFlags.String("hostname", "", "The server on which the tablet is running")
mysqlHost := subFlags.String("mysql_host", "", "The mysql host for the mysql server")
mysqlPort := subFlags.Int("mysql_port", 0, "The mysql port for the mysql server")
port := subFlags.Int("port", 0, "The main port for the vttablet process")
grpcPort := subFlags.Int("grpc_port", 0, "The gRPC port for the vttablet process")
keyspace := subFlags.String("keyspace", "", "The keyspace to which this tablet belongs")
shard := subFlags.String("shard", "", "The shard to which this tablet belongs")

var tags flagutil.StringMapValue
subFlags.Var(&tags, "tags", "A comma-separated list of key:value pairs that are used to tag the tablet")
if err := subFlags.Parse(args); err != nil {
return err
}

if subFlags.NArg() != 2 {
return fmt.Errorf("the <tablet alias> and <tablet type> arguments are both required for the InitTablet command")
}
tabletAlias, err := topoproto.ParseTabletAlias(subFlags.Arg(0))
if err != nil {
return err
}
tabletType, err := parseTabletType(subFlags.Arg(1), topoproto.AllTabletTypes)
if err != nil {
return err
}

// create tablet record
tablet := &topodatapb.Tablet{
Alias: tabletAlias,
Hostname: *hostname,
MysqlHostname: *mysqlHost,
PortMap: make(map[string]int32),
Keyspace: *keyspace,
Shard: *shard,
Type: tabletType,
DbNameOverride: *dbNameOverride,
Tags: tags,
}
if *port != 0 {
tablet.PortMap["vt"] = int32(*port)
}
if *mysqlPort != 0 {
tablet.MysqlPort = int32(*mysqlPort)
}
if *grpcPort != 0 {
tablet.PortMap["grpc"] = int32(*grpcPort)
}

return wr.TopoServer().InitTablet(ctx, tablet, *allowPrimaryOverride, *createShardAndKeyspace, *allowUpdate)
}

func commandGetTablet(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
if err := subFlags.Parse(args); err != nil {
return err
Expand All @@ -985,51 +906,6 @@ func commandGetTablet(ctx context.Context, wr *wrangler.Wrangler, subFlags *pfla
return printJSON(wr.Logger(), tabletInfo.Tablet)
}

func commandUpdateTabletAddrs(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
hostname := subFlags.String("hostname", "", "The fully qualified host name of the server on which the tablet is running.")
mysqlHost := subFlags.String("mysql_host", "", "The mysql host for the mysql server")
mysqlPort := subFlags.Int("mysql-port", 0, "The mysql port for the mysql daemon")
vtPort := subFlags.Int("vt-port", 0, "The main port for the vttablet process")
grpcPort := subFlags.Int("grpc-port", 0, "The gRPC port for the vttablet process")
if err := subFlags.Parse(args); err != nil {
return err
}

if subFlags.NArg() != 1 {
return fmt.Errorf("the <tablet alias> argument is required for the UpdateTabletAddrs command")
}

tabletAlias, err := topoproto.ParseTabletAlias(subFlags.Arg(0))
if err != nil {
return err
}

_, err = wr.TopoServer().UpdateTabletFields(ctx, tabletAlias, func(tablet *topodatapb.Tablet) error {
if *hostname != "" {
tablet.Hostname = *hostname
}
if *mysqlHost != "" {
tablet.MysqlHostname = *mysqlHost
}
if *vtPort != 0 || *grpcPort != 0 || *mysqlPort != 0 {
if tablet.PortMap == nil {
tablet.PortMap = make(map[string]int32)
}
if *vtPort != 0 {
tablet.PortMap["vt"] = int32(*vtPort)
}
if *grpcPort != 0 {
tablet.PortMap["grpc"] = int32(*grpcPort)
}
if *mysqlPort != 0 {
tablet.MysqlPort = int32(*mysqlPort)
}
}
return nil
})
return err
}

func commandDeleteTablet(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
allowPrimary := subFlags.Bool("allow_primary", false, "Allows for the primary tablet of a shard to be deleted. Use with caution.")

Expand Down Expand Up @@ -1328,35 +1204,6 @@ func commandExecuteFetchAsDba(ctx context.Context, wr *wrangler.Wrangler, subFla
return nil
}

func commandVReplicationExec(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
wr.Logger().Printf("\nWARNING: VReplicationExec is deprecated and will be removed in a future release. Please use 'Workflow -- <keyspace.workflow> <action>' instead.\n\n")

json := subFlags.Bool("json", false, "Output JSON instead of human-readable table")

if err := subFlags.Parse(args); err != nil {
return err
}
if subFlags.NArg() != 2 {
return fmt.Errorf("the <tablet alias> and <sql command> arguments are required for the VReplicationExec command")
}

alias, err := topoproto.ParseTabletAlias(subFlags.Arg(0))
if err != nil {
return err
}
query := subFlags.Arg(1)
qrproto, err := wr.VReplicationExec(ctx, alias, query)
if err != nil {
return err
}
qr := sqltypes.Proto3ToResult(qrproto)
if *json {
return printJSON(wr.Logger(), qr)
}
printQueryResult(loggerWriter{wr.Logger()}, qr)
return nil
}

func commandExecuteHook(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
subFlags.SetInterspersed(false) // all flags should be treated as posargs to pass them to the actual hook

Expand Down
Loading