From 7820f3cf64463fb76661960321b49bcd8f338814 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Wed, 14 Feb 2024 08:32:57 -0500 Subject: [PATCH 1/3] Remove deprecated vtctl commands These commands were deprecated even before the vtctldclient migration, so they are doubly-safe to remove. Signed-off-by: Andrew Mason --- go/vt/vtctl/reparent.go | 32 --------- go/vt/vtctl/vtctl.go | 153 ---------------------------------------- 2 files changed, 185 deletions(-) diff --git a/go/vt/vtctl/reparent.go b/go/vt/vtctl/reparent.go index 4498228d9c7..03d1620b638 100644 --- a/go/vt/vtctl/reparent.go +++ b/go/vt/vtctl/reparent.go @@ -38,14 +38,6 @@ func init() { params: "", 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=] ", - 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, @@ -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, 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)") diff --git a/go/vt/vtctl/vtctl.go b/go/vt/vtctl/vtctl.go index 919783e2f76..4622bf0ee4c 100644 --- a/go/vt/vtctl/vtctl.go +++ b/go/vt/vtctl/vtctl.go @@ -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" @@ -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=] [--hostname=] [--mysql_port=] [--port=] [--grpc_port=] [--tags=tag1:value1,tag2:value2] --keyspace= --shard= ", - help: "Initializes a tablet in the topology.", - deprecated: true, - }, { name: "GetTablet", method: commandGetTablet, params: "", help: "Outputs a JSON structure that contains information about the Tablet.", }, - { - name: "UpdateTabletAddrs", - method: commandUpdateTabletAddrs, - params: "[--hostname ] [--ip-addr ] [--mysql-port ] [--vt-port ] [--grpc-port ] ", - help: "Updates the IP address and port numbers of a tablet.", - deprecated: true, - }, { name: "DeleteTablet", method: commandDeleteTablet, @@ -276,14 +261,6 @@ var commands = []commandGroup{ params: "[--max_rows=10000] [--disable_binlogs] [--json] ", help: "Runs the given SQL command as a DBA on the remote tablet.", }, - { - name: "VReplicationExec", - method: commandVReplicationExec, - params: "[--json] ", - help: "Runs the given VReplication command on the remote tablet.", - deprecated: true, - deprecatedBy: "Workflow -- ", - }, }, }, { @@ -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 and 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 @@ -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 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.") @@ -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 -- ' 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 and 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 From c7c4319248bab624f4c93ad1f27d9cc60555db35 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Wed, 6 Mar 2024 10:54:01 -0500 Subject: [PATCH 2/3] fix test Signed-off-by: Andrew Mason --- .../encryption/encryptedtransport/encrypted_transport_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/test/endtoend/encryption/encryptedtransport/encrypted_transport_test.go b/go/test/endtoend/encryption/encryptedtransport/encrypted_transport_test.go index b076006ec2c..5747274e1bf 100644 --- a/go/test/endtoend/encryption/encryptedtransport/encrypted_transport_test.go +++ b/go/test/endtoend/encryption/encryptedtransport/encrypted_transport_test.go @@ -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) From b52a0eac54592c1ac5bb3f05804fed3335a72ec4 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Wed, 6 Mar 2024 11:09:50 -0500 Subject: [PATCH 3/3] clarify log message Signed-off-by: Andrew Mason --- go/test/endtoend/cluster/vtctl_process.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/test/endtoend/cluster/vtctl_process.go b/go/test/endtoend/cluster/vtctl_process.go index b9d8a5b46ce..70b1297e54f 100644 --- a/go/test/endtoend/cluster/vtctl_process.go +++ b/go/test/endtoend/cluster/vtctl_process.go @@ -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 } @@ -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() }