Documentation ¶
Overview ¶
Package command contains the commands used by vtctldclient. It is intended only for use in vtctldclient's main package and entrypoint. The rest of this documentation is intended for maintainers.
Commands are grouped into files by the types of resources they interact with ( e.g. GetTablet, CreateTablet, DeleteTablet, GetTablets) or by what they do (e.g. PlannedReparentShard, EmergencyReparentShard, InitShardPrimary). Please add the command to the appropriate existing file, alphabetically, or create a new grouping if one does not exist.
The root command lives in root.go, and commands must attach themselves to this during an init function in order to be reachable from the CLI. root.go also contains the global variables available to any subcommand that are managed by the root command's pre- and post-run functions. Commands must not attempt to manage these, as that may conflict with Root's post-run cleanup actions. All commands should, at a minimum, use the commandCtx rather than creating their own context.Background to start, as it contains root tracing spans that would be lost.
Commands should not keep their logic in an anonymous function on the cobra.Command struct, but instead in a separate function that is assigned to RunE. Commands should strive to keep declaration, function definition, and flag initialization located as closely together as possible, to make the code easier to follow and understand (the global variables declared near Root are the exception here, not the rule). Commands should also prevent individual flag names from polluting the package namespace.
A good pattern we have found is to do the following:
package command // (imports ...) var ( CreateTablet = &cobra.Command{ Use: "CreateTablet [options] --keyspace=<keyspace> --shard=<shard-range> <tablet-alias> <tablet-type>", Args: cobra.ExactArgs(2), RunE: commandCreateTablet, } GetTablet = &cobra.Command{ Use: "GetTablet <tablet-alias>", Args: cobra.ExactArgs(1), RunE: commandGetTablet, } ) var createTabletOptions = struct { Opt1 string Opt2 bool Keyspace string Shard string }{} func commandCreateTablet(cmd *cobra.Command, args []string) error { aliasStr := cmd.Flags().Args(0) tabletTypeStr := cmd.Flags().Args(1) // do stuff with: // - client // - commandCtx // - createTabletOptions // - aliasStr // - tabletTypeStr return nil } // GetTablet takes no flags, so it needs no anonymous struct to store them func commandGetTablet(cmd *cobra.Command, args []string) error { aliasStr := cmd.Flags().Arg(0) // do stuff with: // - client // - commandCtx // - aliasStr return nil } // finally, hook up all the commands in this file to Root, and add any flags // to each of those commands func init() { CreateTablet.Flags().StringVar(&createTabletOptions.Opt1, "opt1", "default", "help") CreateTablet.Flags().BoolVar(&createTabletOptions.Opt2, "opt2", false, "help") CreateTablet.Flags().StringVarP(&createTabletOptions.Keyspace, "keyspace", "k", "keyspace of tablet") CreateTablet.MarkFlagRequired("keyspace") CreateTablet.Flags().StringVarP(&createTabletOptions.Shard, "shard", "s", "shard range of tablet") CreateTablet.MarkFlagRequired("shard") Root.AddCommand(CreateTablet) Root.AddCommand(GetTablet) }
A note on RunE and SilenceUsage:
We prefer using RunE over Run for the entrypoint to our subcommands, because it allows us return errors back up to the vtctldclient main function and do error handling, logging, and exit-code management once, in one place, rather than on a per-command basis. However, cobra treats errors returned from a command's RunE as usage errors, and therefore will print the command's full usage text to stderr when RunE returns non-nil, in addition to propagating that error back up to the result of the root command's Execute() method. This is decidedly not what we want. There is no plan to address this in cobra v1. 1
The suggested workaround for this issue is to set SilenceUsage: true, either on the root command or on every subcommand individually. This also does not work for vtctldclient, because not every flag can be parsed during pflag.Parse time, and for certain flags (mutually exclusive options, optional flags that require other flags to be set with them, etc) we do additional parsing and validation of flags in an individual subcommand. We want errors during this phase to be treated as usage errors, so setting SilenceUsage=true before this point would not cause usage text to be printed for us.
So, for us, we want to individually set cmd.SilenceUsage = true at *particular points* in each command, dependending on whether that command needs to do an additional parse & validation pass. In most cases, the command does not need to post-validate its options, and can set cmd.SilencUsage = true as their first line. We feel, though, that a line that reads "SilenceUsage = true" to be potentially confusing in how it reads. A maintainer without sufficient context may read this and say "Silence usage? We don't want that" and remove the lines, so we provide a wrapper function that communicates intent, cli.FinishedParsing, that each subcommand should call when they have transitioned from the parsing & validation phase of their entrypoint to the actual logic.
Copyright 2023 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
const (
AllMigrationsIndicator = "all"
)
Variables ¶
var ( // Backup makes a Backup gRPC call to a vtctld. Backup = &cobra.Command{ Use: "Backup [--concurrency <concurrency>] [--allow-primary] [--incremental-from-pos=<pos>|auto] [--upgrade-safe] <tablet_alias>", Short: "Uses the BackupStorage service on the given tablet to create and store a new backup.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandBackup, } // BackupShard makes a BackupShard gRPC call to a vtctld. BackupShard = &cobra.Command{ Use: "BackupShard [--concurrency <concurrency>] [--allow-primary] [--incremental-from-pos=<pos>|auto] [--upgrade-safe] <keyspace/shard>", Short: "Finds the most up-to-date REPLICA, RDONLY, or SPARE tablet in the given shard and uses the BackupStorage service on that tablet to create and store a new backup.", Long: `Finds the most up-to-date REPLICA, RDONLY, or SPARE tablet in the given shard and uses the BackupStorage service on that tablet to create and store a new backup. If no replica-type tablet can be found, the backup can be taken on the primary if --allow-primary is specified.`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandBackupShard, } // GetBackups makes a GetBackups gRPC call to a vtctld. GetBackups = &cobra.Command{ Use: "GetBackups [--limit <limit>] [--json] <keyspace/shard>", Short: "Lists backups for the given shard.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandGetBackups, } // RemoveBackup makes a RemoveBackup gRPC call to a vtctld. RemoveBackup = &cobra.Command{ Use: "RemoveBackup <keyspace/shard> <backup name>", Short: "Removes the given backup from the BackupStorage used by vtctld.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandRemoveBackup, } // RestoreFromBackup makes a RestoreFromBackup gRPC call to a vtctld. RestoreFromBackup = &cobra.Command{ Use: "RestoreFromBackup [--backup-timestamp|-t <YYYY-mm-DD.HHMMSS>] [--restore-to-pos <pos>] [--dry-run] <tablet_alias>", Short: "Stops mysqld on the specified tablet and restores the data from either the latest backup or closest before `backup-timestamp`.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandRestoreFromBackup, } )
var ( // AddCellInfo makes an AddCellInfo gRPC call to a vtctld. AddCellInfo = &cobra.Command{ Use: "AddCellInfo --root <root> [--server-address <addr>] <cell>", Short: "Registers a local topology service in a new cell by creating the CellInfo.", Long: `Registers a local topology service in a new cell by creating the CellInfo with the provided parameters. The address will be used to connect to the topology service, and Vitess data will be stored starting at the provided root.`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandAddCellInfo, } // AddCellsAlias makes an AddCellsAlias gRPC call to a vtctld. AddCellsAlias = &cobra.Command{ Use: "AddCellsAlias --cells <cell1,cell2,...> [--cells <cell3> ...] <alias>", Short: "Defines a group of cells that can be referenced by a single name (the alias).", Long: `Defines a group of cells that can be referenced by a single name (the alias). When routing query traffic, replica/rdonly traffic can be routed across cells within the group (alias). Only primary traffic can be routed across cells not in the same group (alias).`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandAddCellsAlias, } // DeleteCellInfo makes a DeleteCellInfo gRPC call to a vtctld. DeleteCellInfo = &cobra.Command{ Use: "DeleteCellInfo [--force] <cell>", Short: "Deletes the CellInfo for the provided cell.", Long: "Deletes the CellInfo for the provided cell. The cell cannot be referenced by any Shard record.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandDeleteCellInfo, } // DeleteCellsAlias makes a DeleteCellsAlias gRPC call to a vtctld. DeleteCellsAlias = &cobra.Command{ Use: "DeleteCellsAlias <alias>", Short: "Deletes the CellsAlias for the provided alias.", Long: "Deletes the CellsAlias for the provided alias.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandDeleteCellsAlias, } // GetCellInfoNames makes a GetCellInfoNames gRPC call to a vtctld. GetCellInfoNames = &cobra.Command{ Use: "GetCellInfoNames", Short: "Lists the names of all cells in the cluster.", DisableFlagsInUseLine: true, Args: cobra.NoArgs, RunE: commandGetCellInfoNames, } // GetCellInfo makes a GetCellInfo gRPC call to a vtctld. GetCellInfo = &cobra.Command{ Use: "GetCellInfo <cell>", Short: "Gets the CellInfo object for the given cell.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandGetCellInfo, } // GetCellsAliases makes a GetCellsAliases gRPC call to a vtctld. GetCellsAliases = &cobra.Command{ Use: "GetCellsAliases", Short: "Gets all CellsAlias objects in the cluster.", DisableFlagsInUseLine: true, Args: cobra.NoArgs, RunE: commandGetCellsAliases, } // UpdateCellInfo makes an UpdateCellInfo gRPC call to a vtctld. UpdateCellInfo = &cobra.Command{ Use: "UpdateCellInfo [--root <root>] [--server-address <addr>] <cell>", Short: "Updates the content of a CellInfo with the provided parameters, creating the CellInfo if it does not exist.", Long: `Updates the content of a CellInfo with the provided parameters, creating the CellInfo if it does not exist. If a value is empty, it is ignored.`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandUpdateCellInfo, } // UpdateCellsAlias makes an UpdateCellsAlias gRPC call to a vtctld. UpdateCellsAlias = &cobra.Command{ Use: "UpdateCellsAlias [--cells <cell1,cell2,...> [--cells <cell4> ...]] <alias>", Short: "Updates the content of a CellsAlias with the provided parameters, creating the CellsAlias if it does not exist.", Long: "Updates the content of a CellsAlias with the provided parameters, creating the CellsAlias if it does not exist.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandUpdateCellsAlias, } )
var ( // CreateKeyspace makes a CreateKeyspace gRPC call to a vtctld. CreateKeyspace = &cobra.Command{ Use: "CreateKeyspace <keyspace> [--force|-f] [--type KEYSPACE_TYPE] [--base-keyspace KEYSPACE --snapshot-timestamp TIME] [--served-from DB_TYPE:KEYSPACE ...] [--durability-policy <policy_name>] [--sidecar-db-name <db_name>]", Short: "Creates the specified keyspace in the topology.", Long: `Creates the specified keyspace in the topology. For a SNAPSHOT keyspace, the request must specify the name of a base keyspace, as well as a snapshot time.`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandCreateKeyspace, } // DeleteKeyspace makes a DeleteKeyspace gRPC call to a vtctld. DeleteKeyspace = &cobra.Command{ Use: "DeleteKeyspace [--recursive|-r] [--force|-f] <keyspace>", Short: "Deletes the specified keyspace from the topology.", Long: `Deletes the specified keyspace from the topology. In recursive mode, it also recursively deletes all shards in the keyspace. Otherwise, the keyspace must be empty (have no shards), or returns an error.`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandDeleteKeyspace, } // FindAllShardsInKeyspace makes a FindAllShardsInKeyspace gRPC call to a vtctld. FindAllShardsInKeyspace = &cobra.Command{ Use: "FindAllShardsInKeyspace <keyspace>", Short: "Returns a map of shard names to shard references for a given keyspace.", DisableFlagsInUseLine: true, Aliases: []string{"findallshardsinkeyspace"}, Args: cobra.ExactArgs(1), RunE: commandFindAllShardsInKeyspace, } // GetKeyspace makes a GetKeyspace gRPC call to a vtctld. GetKeyspace = &cobra.Command{ Use: "GetKeyspace <keyspace>", Short: "Returns information about the given keyspace from the topology.", DisableFlagsInUseLine: true, Aliases: []string{"getkeyspace"}, Args: cobra.ExactArgs(1), RunE: commandGetKeyspace, } // GetKeyspaces makes a GetKeyspaces gRPC call to a vtctld. GetKeyspaces = &cobra.Command{ Use: "GetKeyspaces", Short: "Returns information about every keyspace in the topology.", DisableFlagsInUseLine: true, Aliases: []string{"getkeyspaces"}, Args: cobra.NoArgs, RunE: commandGetKeyspaces, } // RemoveKeyspaceCell makes a RemoveKeyspaceCell gRPC call to a vtctld. RemoveKeyspaceCell = &cobra.Command{ Use: "RemoveKeyspaceCell [--force|-f] [--recursive|-r] <keyspace> <cell>", Short: "Removes the specified cell from the Cells list for all shards in the specified keyspace (by calling RemoveShardCell on every shard). It also removes the SrvKeyspace for that keyspace in that cell.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandRemoveKeyspaceCell, } // SetKeyspaceDurabilityPolicy makes a SetKeyspaceDurabilityPolicy gRPC call to a vtcltd. SetKeyspaceDurabilityPolicy = &cobra.Command{ Use: "SetKeyspaceDurabilityPolicy [--durability-policy=policy_name] <keyspace name>", Short: "Sets the durability-policy used by the specified keyspace.", Long: `Sets the durability-policy used by the specified keyspace. Durability policy governs the durability of the keyspace by describing which tablets should be sending semi-sync acknowledgements to the primary. Possible values include 'semi_sync', 'none' and others as dictated by registered plugins. To set the durability policy of customer keyspace to semi_sync, you would use the following command: SetKeyspaceDurabilityPolicy --durability-policy='semi_sync' customer`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandSetKeyspaceDurabilityPolicy, } // ValidateSchemaKeyspace makes a ValidateSchemaKeyspace gRPC call to a vtctld. ValidateSchemaKeyspace = &cobra.Command{ Use: "ValidateSchemaKeyspace [--exclude-tables=<exclude_tables>] [--include-views] [--skip-no-primary] [--include-vschema] <keyspace>", Short: "Validates that the schema on the primary tablet for shard 0 matches the schema on all other tablets in the keyspace.", DisableFlagsInUseLine: true, Aliases: []string{"validateschemakeyspace"}, Args: cobra.ExactArgs(1), RunE: commandValidateSchemaKeyspace, } // ValidateVersionKeyspace makes a ValidateVersionKeyspace gRPC call to a vtctld. ValidateVersionKeyspace = &cobra.Command{ Use: "ValidateVersionKeyspace <keyspace>", Short: "Validates that the version on the primary tablet of shard 0 matches all of the other tablets in the keyspace.", DisableFlagsInUseLine: true, Aliases: []string{"validateversionkeyspace"}, Args: cobra.ExactArgs(1), RunE: commandValidateVersionKeyspace, } )
var ( OnlineDDL = &cobra.Command{ Use: "OnlineDDL <cmd> <keyspace> [args]", Short: "Operates on online DDL (schema migrations).", DisableFlagsInUseLine: true, Args: cobra.MinimumNArgs(2), } OnlineDDLCancel = &cobra.Command{ Use: "cancel <keyspace> <uuid|all>", Short: "Cancel one or all migrations, terminating any running ones as needed.", Example: "OnlineDDL cancel test_keyspace 82fa54ac_e83e_11ea_96b7_f875a4d24e90", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandOnlineDDLCancel, } OnlineDDLCleanup = &cobra.Command{ Use: "cleanup <keyspace> <uuid>", Short: "Mark a given schema migration ready for artifact cleanup.", Example: "OnlineDDL cleanup test_keyspace 82fa54ac_e83e_11ea_96b7_f875a4d24e90", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandOnlineDDLCleanup, } OnlineDDLComplete = &cobra.Command{ Use: "complete <keyspace> <uuid|all>", Short: "Complete one or all migrations executed with --postpone-completion", Example: "OnlineDDL complete test_keyspace 82fa54ac_e83e_11ea_96b7_f875a4d24e90", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandOnlineDDLComplete, } OnlineDDLLaunch = &cobra.Command{ Use: "launch <keyspace> <uuid|all>", Short: "Launch one or all migrations executed with --postpone-launch", Example: "OnlineDDL launch test_keyspace 82fa54ac_e83e_11ea_96b7_f875a4d24e90", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandOnlineDDLLaunch, } OnlineDDLRetry = &cobra.Command{ Use: "retry <keyspace> <uuid>", Short: "Mark a given schema migration for retry.", Example: "vtctl OnlineDDL retry test_keyspace 82fa54ac_e83e_11ea_96b7_f875a4d24e90", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandOnlineDDLRetry, } OnlineDDLThrottle = &cobra.Command{ Use: "throttle <keyspace> <uuid|all>", Short: "Throttles one or all migrations", Example: "OnlineDDL throttle all", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandOnlineDDLThrottle, } OnlineDDLUnthrottle = &cobra.Command{ Use: "unthrottle <keyspace> <uuid|all>", Short: "Unthrottles one or all migrations", Example: "OnlineDDL unthrottle all", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandOnlineDDLUnthrottle, } OnlineDDLShow = &cobra.Command{ Use: "show", Short: "Display information about online DDL operations.", Example: `OnlineDDL show test_keyspace 82fa54ac_e83e_11ea_96b7_f875a4d24e90 OnlineDDL show test_keyspace all OnlineDDL show --order descending test_keyspace all OnlineDDL show --limit 10 test_keyspace all OnlineDDL show --skip 5 --limit 10 test_keyspace all OnlineDDL show test_keyspace running OnlineDDL show test_keyspace complete OnlineDDL show test_keyspace failed`, DisableFlagsInUseLine: true, Args: cobra.RangeArgs(1, 2), RunE: commandOnlineDDLShow, } )
var ( // ExecuteFetchAsApp makes an ExecuteFetchAsApp gRPC call to a vtctld. ExecuteFetchAsApp = &cobra.Command{ Use: "ExecuteFetchAsApp [--max-rows <max-rows>] [--json|-j] [--use-pool] <tablet-alias> <query>", Short: "Executes the given query as the App user on the remote tablet.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandExecuteFetchAsApp, } // ExecuteFetchAsDBA makes an ExecuteFetchAsDBA gRPC call to a vtctld. ExecuteFetchAsDBA = &cobra.Command{ Use: "ExecuteFetchAsDBA [--max-rows <max-rows>] [--json|-j] [--disable-binlogs] [--reload-schema] <tablet alias> <query>", Short: "Executes the given query as the DBA user on the remote tablet.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandExecuteFetchAsDBA, Aliases: []string{"ExecuteFetchAsDba"}, } )
var ( // EmergencyReparentShard makes an EmergencyReparent gRPC call to a vtctld. EmergencyReparentShard = &cobra.Command{ Use: "EmergencyReparentShard <keyspace/shard>", Short: "Reparents the shard to the new primary. Assumes the old primary is dead and not responding.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandEmergencyReparentShard, } // InitShardPrimary makes an InitShardPrimary gRPC call to a vtctld. InitShardPrimary = &cobra.Command{ Use: "InitShardPrimary <keyspace/shard> <primary alias>", Short: "Sets the initial primary for the shard.", Long: `Sets the initial primary for the shard. This will make all other tablets in the shard become replicas of the promoted tablet. WARNING: this can cause data loss on an already-replicating shard. PlannedReparentShard or EmergencyReparentShard should be used instead. `, DisableFlagsInUseLine: true, Deprecated: "Please use PlannedReparentShard instead", Args: cobra.ExactArgs(2), RunE: commandInitShardPrimary, } // PlannedReparentShard makes a PlannedReparentShard gRPC call to a vtctld. PlannedReparentShard = &cobra.Command{ Use: "PlannedReparentShard <keyspace/shard>", Short: "Reparents the shard to a new primary, or away from an old primary. Both the old and new primaries must be up and running.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandPlannedReparentShard, } // ReparentTablet makes a ReparentTablet gRPC call to a vtctld. ReparentTablet = &cobra.Command{ Use: "ReparentTablet <alias>", Short: "Reparent a tablet to the current primary in the shard.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandReparentTablet, } // TabletExternallyReparented makes a TabletExternallyReparented gRPC call // to a vtctld. TabletExternallyReparented = &cobra.Command{ Use: "TabletExternallyReparented <alias>", Short: "Updates the topology record for the tablet's shard to acknowledge that an external tool made this tablet the primary.", Long: `Updates the topology record for the tablet's shard to acknowledge that an external tool made this tablet the primary. See the Reparenting guide for more information: https://vitess.io/docs/user-guides/configuration-advanced/reparenting/#external-reparenting. `, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandTabletExternallyReparented, } )
var ( // VtctldClientProtocol is the protocol to use when creating the vtctldclient.VtctldClient. VtctldClientProtocol = "grpc" // Root is the main entrypoint to the vtctldclient CLI. Root = &cobra.Command{ Use: "vtctldclient", Short: "Executes a cluster management command on the remote vtctld server.", PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) { logutil.PurgeLogs() traceCloser = trace.StartTracing("vtctldclient") client, err = getClientForCommand(cmd) ctx := cmd.Context() if ctx == nil { ctx = context.Background() } commandCtx, commandCancel = context.WithTimeout(ctx, actionTimeout) if compactOutput { cli.DefaultMarshalOptions.EmitUnpopulated = false } vreplcommon.SetClient(client) vreplcommon.SetCommandCtx(commandCtx) return err }, PersistentPostRunE: func(cmd *cobra.Command, args []string) (err error) { commandCancel() if client != nil { err = client.Close() } trace.LogErrorsWhenClosing(traceCloser) return err }, TraverseChildren: true, SilenceErrors: true, Version: servenv.AppVersion.String(), RunE: func(cmd *cobra.Command, args []string) error { if cmd.Flags().NArg() > 0 { return fmt.Errorf("unknown command: %s", cmd.Flags().Arg(0)) } return nil }, } )
var ( // ApplyRoutingRules makes an ApplyRoutingRules gRPC call to a vtctld. ApplyRoutingRules = &cobra.Command{ Use: "ApplyRoutingRules {--rules RULES | --rules-file RULES_FILE} [--cells=c1,c2,...] [--skip-rebuild] [--dry-run]", Short: "Applies the VSchema routing rules.", DisableFlagsInUseLine: true, Args: cobra.NoArgs, RunE: commandApplyRoutingRules, } // GetRoutingRules makes a GetRoutingRules gRPC call to a vtctld. GetRoutingRules = &cobra.Command{ Use: "GetRoutingRules", Short: "Displays the VSchema routing rules.", DisableFlagsInUseLine: true, Args: cobra.NoArgs, RunE: commandGetRoutingRules, } )
var ( // ApplySchema makes an ApplySchema gRPC call to a vtctld. ApplySchema = &cobra.Command{ Use: "ApplySchema [--ddl-strategy <strategy>] [--uuid <uuid> ...] [--migration-context <context>] [--wait-replicas-timeout <duration>] [--caller-id <caller_id>] {--sql-file <file> | --sql <sql>} <keyspace>", Short: "Applies the schema change to the specified keyspace on every primary, running in parallel on all shards. The changes are then propagated to replicas via replication.", Long: `Applies the schema change to the specified keyspace on every primary, running in parallel on all shards. The changes are then propagated to replicas via replication. If --allow-long-unavailability is set, schema changes affecting a large number of rows (and possibly incurring a longer period of unavailability) will not be rejected. --ddl-strategy is used to instruct migrations via vreplication, gh-ost or pt-osc with optional parameters. --migration-context allows the user to specify a custom migration context for online DDL migrations. If --skip-preflight, SQL goes directly to shards without going through sanity checks. The --uuid and --sql flags are repeatable, so they can be passed multiple times to build a list of values. For --uuid, this is used like "--uuid $first_uuid --uuid $second_uuid". For --sql, semi-colons and repeated values may be mixed, for example: ApplySchema --sql "CREATE TABLE my_table; CREATE TABLE my_other_table" ApplySchema --sql "CREATE TABLE my_table" --sql "CREATE TABLE my_other_table"`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandApplySchema, } // GetSchema makes a GetSchema gRPC call to a vtctld. GetSchema = &cobra.Command{ Use: "GetSchema [--tables TABLES ...] [--exclude-tables EXCLUDE_TABLES ...] [{--table-names-only | --table-sizes-only}] [--include-views] alias", Short: "Displays the full schema for a tablet, optionally restricted to the specified tables/views.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandGetSchema, } // ReloadSchema makes a ReloadSchema gRPC call to a vtctld. ReloadSchema = &cobra.Command{ Use: "ReloadSchema <tablet_alias>", Short: "Reloads the schema on a remote tablet.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandReloadSchema, } // ReloadSchemaKeyspace makes a ReloadSchemaKeyspace gRPC call to a vtctld. ReloadSchemaKeyspace = &cobra.Command{ Use: "ReloadSchemaKeyspace [--concurrency=<concurrency>] [--include-primary] <keyspace>", Short: "Reloads the schema on all tablets in a keyspace. This is done on a best-effort basis.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandReloadSchemaKeyspace, } // ReloadSchemaShard makes a ReloadSchemaShard gRPC call to a vtctld. ReloadSchemaShard = &cobra.Command{ Use: "ReloadSchemaShard [--concurrency=10] [--include-primary] <keyspace/shard>", Short: "Reloads the schema on all tablets in a shard. This is done on a best-effort basis.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandReloadSchemaShard, } )
var ( // DeleteSrvVSchema makes a DeleteSrvVSchema gRPC call to a vtctld. DeleteSrvVSchema = &cobra.Command{ Use: "DeleteSrvVSchema <cell>", Short: "Deletes the SrvVSchema object in the given cell.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandDeleteSrvVSchema, } // GetSrvKeyspaceNames makes a GetSrvKeyspaceNames gRPC call to a vtctld. GetSrvKeyspaceNames = &cobra.Command{ Use: "GetSrvKeyspaceNames [<cell> ...]", Short: "Outputs a JSON mapping of cell=>keyspace names served in that cell. Omit to query all cells.", DisableFlagsInUseLine: true, Args: cobra.ArbitraryArgs, RunE: commandGetSrvKeyspaceNames, } // GetSrvKeyspaces makes a GetSrvKeyspaces gRPC call to a vtctld. GetSrvKeyspaces = &cobra.Command{ Use: "GetSrvKeyspaces <keyspace> [<cell> ...]", Short: "Returns the SrvKeyspaces for the given keyspace in one or more cells.", DisableFlagsInUseLine: true, Args: cobra.MinimumNArgs(1), RunE: commandGetSrvKeyspaces, } // GetSrvVSchema makes a GetSrvVSchema gRPC call to a vtctld. GetSrvVSchema = &cobra.Command{ Use: "GetSrvVSchema cell", Short: "Returns the SrvVSchema for the given cell.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandGetSrvVSchema, } // GetSrvVSchemas makes a GetSrvVSchemas gRPC call to a vtctld. GetSrvVSchemas = &cobra.Command{ Use: "GetSrvVSchemas [<cell> ...]", Short: "Returns the SrvVSchema for all cells, optionally filtered by the given cells.", DisableFlagsInUseLine: true, Args: cobra.ArbitraryArgs, RunE: commandGetSrvVSchemas, } // RebuildKeyspaceGraph makes one or more RebuildKeyspaceGraph gRPC calls to a vtctld. RebuildKeyspaceGraph = &cobra.Command{ Use: "RebuildKeyspaceGraph [--cells=c1,c2,...] [--allow-partial] ks1 [ks2 ...]", Short: "Rebuilds the serving data for the keyspace(s). This command may trigger an update to all connected clients.", DisableFlagsInUseLine: true, Args: cobra.MinimumNArgs(1), RunE: commandRebuildKeyspaceGraph, } // RebuildVSchemaGraph makes a RebuildVSchemaGraph gRPC call to a vtctld. RebuildVSchemaGraph = &cobra.Command{ Use: "RebuildVSchemaGraph [--cells=c1,c2,...]", Short: "Rebuilds the cell-specific SrvVSchema from the global VSchema objects in the provided cells (or all cells if none provided).", DisableFlagsInUseLine: true, Args: cobra.NoArgs, RunE: commandRebuildVSchemaGraph, } )
var ( // ApplyShardRoutingRules makes an ApplyShardRoutingRules gRPC call to a vtctld. ApplyShardRoutingRules = &cobra.Command{ Use: "ApplyShardRoutingRules {--rules RULES | --rules-file RULES_FILE} [--cells=c1,c2,...] [--skip-rebuild] [--dry-run]", Short: "Applies the provided shard routing rules.", DisableFlagsInUseLine: true, Args: cobra.NoArgs, RunE: commandApplyShardRoutingRules, } // GetShardRoutingRules makes a GetShardRoutingRules gRPC call to a vtctld. GetShardRoutingRules = &cobra.Command{ Use: "GetShardRoutingRules", Short: "Displays the currently active shard routing rules as a JSON document.", Long: `Displays the currently active shard routing rules as a JSON document. See the documentation on shard level migrations[1] for more information. [1]: https://vitess.io/docs/reference/vreplication/shardlevelmigrations/`, DisableFlagsInUseLine: true, Args: cobra.NoArgs, RunE: commandGetShardRoutingRules, } )
var ( // CreateShard makes a CreateShard gRPC request to a vtctld. CreateShard = &cobra.Command{ Use: "CreateShard [--force|-f] [--include-parent|-p] <keyspace/shard>", Short: "Creates the specified shard in the topology.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandCreateShard, } // DeleteShards makes a DeleteShards gRPC request to a vtctld. DeleteShards = &cobra.Command{ Use: "DeleteShards [--recursive|-r] [--even-if-serving] [--force|-f] <keyspace/shard> [<keyspace/shard> ...]", Short: "Deletes the specified shards from the topology.", Long: `Deletes the specified shards from the topology. In recursive mode, it also deletes all tablets belonging to the shard. Otherwise, the shard must be empty (have no tablets) or returns an error for that shard.`, DisableFlagsInUseLine: true, Args: cobra.MinimumNArgs(1), RunE: commandDeleteShards, } // GenerateShardRanges outputs a set of shard ranges assuming a (mostly) // equal distribution of N shards. GenerateShardRanges = &cobra.Command{ Use: "GenerateShardRanges <num_shards>", Short: "Print a set of shard ranges assuming a keyspace with N shards.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { n, err := strconv.Atoi(cmd.Flags().Arg(0)) if err != nil { return err } cli.FinishedParsing(cmd) shards, err := key.GenerateShardRanges(n) if err != nil { return err } data, err := cli.MarshalJSON(shards) if err != nil { return err } fmt.Printf("%s\n", data) return nil }, Annotations: map[string]string{ skipClientCreationKey: "true", }, } // GetShard makes a GetShard gRPC request to a vtctld. GetShard = &cobra.Command{ Use: "GetShard <keyspace/shard>", Short: "Returns information about a shard in the topology.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandGetShard, } // RemoveShardCell makes a RemoveShardCell gRPC request to a vtctld. RemoveShardCell = &cobra.Command{ Use: "RemoveShardCell [--force|-f] [--recursive|-r] <keyspace/shard> <cell>", Short: "Remove the specified cell from the specified shard's Cells list.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandRemoveShardCell, } // SetShardIsPrimaryServing makes a SetShardIsPrimaryServing gRPC call to a // vtctld. SetShardIsPrimaryServing = &cobra.Command{ Use: "SetShardIsPrimaryServing <keyspace/shard> <true/false>", Short: "Add or remove a shard from serving. This is meant as an emergency function. It does not rebuild any serving graphs; i.e. it does not run `RebuildKeyspaceGraph`.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandSetShardIsPrimaryServing, } // SetShardTabletControl makes a SetShardTabletControl gRPC call to a vtctld. SetShardTabletControl = &cobra.Command{ Use: "SetShardTabletControl [--cells=c1,c2...] [--denied-tables=t1,t2,...] [--remove] [--disable-query-service[=0|false]] <keyspace/shard> <tablet_type>", Short: "Sets the TabletControl record for a shard and tablet type. Only use this for an emergency fix or after a finished MoveTables.", Long: `Sets the TabletControl record for a shard and tablet type. Only use this for an emergency fix or after a finished MoveTables. Always specify the denied-tables flag for MoveTables, but never for Reshard operations. To set the DisableQueryService flag, keep denied-tables empty, and set --disable-query-service to true or false. This is useful to fix Reshard operations gone wrong. To change the list of denied tables, specify the --denied-tables parameter with the new list. This is useful to fix tables that are being blocked after a MoveTables operation. To remove the ShardTabletControl record entirely, use the --remove flag. This is useful after a MoveTables has finished to remove serving restrictions.`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandSetShardTabletControl, } // ShardReplicationAdd makse a ShardReplicationAdd gRPC request to a vtctld. ShardReplicationAdd = &cobra.Command{ Use: "ShardReplicationAdd <keyspace/shard> <tablet alias>", Short: "Adds an entry to the replication graph in the given cell.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandShardReplicationAdd, Hidden: true, } // ShardReplicationFix makes a ShardReplicationFix gRPC request to a vtctld. ShardReplicationFix = &cobra.Command{ Use: "ShardReplicationFix <cell> <keyspace/shard>", Short: "Walks through a ShardReplication object and fixes the first error encountered.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandShardReplicationFix, } // ShardReplicationPositions makes a ShardReplicationPositions gRPC request // to a vtctld. ShardReplicationPositions = &cobra.Command{ Use: "ShardReplicationPositions <keyspace/shard>", Long: `Shows the replication status of each tablet in the shard graph. Output is sorted by tablet type, then replication position. Use ctrl-C to interrupt the command and see partial results if needed.`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandShardReplicationPositions, } // ShardReplicationRemove makse a ShardReplicationRemove gRPC request to a vtctld. ShardReplicationRemove = &cobra.Command{ Use: "ShardReplicationRemove <keyspace/shard> <tablet alias>", Short: "Removes an entry from the replication graph in the given cell.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandShardReplicationRemove, Hidden: true, } // SourceShardAdd makes a SourceShardAdd gRPC request to a vtctld. SourceShardAdd = &cobra.Command{ Use: "SourceShardAdd [--key-range <keyrange>] [--tables <table1,table2,...> [--tables <table3,...>]...] <keyspace/shard> <uid> <source keyspace/shard>", Short: "Adds the SourceShard record with the provided index for emergencies only. It does not call RefreshState for the shard primary.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(3), RunE: commandSourceShardAdd, } // SourceShardDelete makes a SourceShardDelete gRPC request to a vtctld. SourceShardDelete = &cobra.Command{ Use: "SourceShardDelete <keyspace/shard> <uid>", Short: "Deletes the SourceShard record with the provided index. This should only be used for emergency cleanup. It does not call RefreshState for the shard primary.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandSourceShardDelete, } // ValidateVersionShard makes a ValidateVersionShard gRPC request to a vtctld. ValidateVersionShard = &cobra.Command{ Use: "ValidateVersionShard <keyspace/shard>", Short: "Validates that the version on the primary matches all of the replicas.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandValidateVersionShard, } )
var ( // ChangeTabletType makes a ChangeTabletType gRPC call to a vtctld. ChangeTabletType = &cobra.Command{ Use: "ChangeTabletType [--dry-run] <alias> <tablet-type>", Short: "Changes the db type for the specified tablet, if possible.", Long: `Changes the db type for the specified tablet, if possible. This command is used primarily to arrange replicas, and it will not convert a primary. NOTE: This command automatically updates the serving graph.`, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandChangeTabletType, } // DeleteTablets makes a DeleteTablets gRPC call to a vtctld. DeleteTablets = &cobra.Command{ Use: "DeleteTablets <alias> [ <alias> ... ]", Short: "Deletes tablet(s) from the topology.", DisableFlagsInUseLine: true, Args: cobra.MinimumNArgs(1), RunE: commandDeleteTablets, } // ExecuteHook makes an ExecuteHook gRPC call to a vtctld. ExecuteHook = &cobra.Command{ Use: "ExecuteHook <alias> <hook_name> [<param1=value1> ...]", Short: "Runs the specified hook on the given tablet.", Long: `Runs the specified hook on the given tablet. A hook is an executable script that resides in the ${VTROOT}/vthook directory. For ExecuteHook, this is on the tablet requested, not on the vtctld or the host running the vtctldclient. Any key-value pairs passed after the hook name will be passed as parameters to the hook on the tablet. Note: hook names may not contain slash (/) characters. `, DisableFlagsInUseLine: true, Args: cobra.MinimumNArgs(2), RunE: commandExecuteHook, } // GetFullStatus makes a FullStatus gRPC call to a vttablet. GetFullStatus = &cobra.Command{ Use: "GetFullStatus <alias>", Short: "Outputs a JSON structure that contains full status of MySQL including the replication information, semi-sync information, GTID information among others.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandGetFullStatus, } // GetPermissions makes a GetPermissions gRPC call to a vtctld. GetPermissions = &cobra.Command{ Use: "GetPermissions <tablet_alias>", Short: "Displays the permissions for a tablet.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandGetPermissions, } // GetTablet makes a GetTablet gRPC call to a vtctld. GetTablet = &cobra.Command{ Use: "GetTablet <alias>", Short: "Outputs a JSON structure that contains information about the tablet.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandGetTablet, } // GetTablets makes a GetTablets gRPC call to a vtctld. GetTablets = &cobra.Command{ Use: "GetTablets [--strict] [{--cell $c1 [--cell $c2 ...] [--tablet-type $t1] [--keyspace $ks [--shard $shard]], --tablet-alias $alias}]", Short: "Looks up tablets according to filter criteria.", Long: fmt.Sprintf(`Looks up tablets according to the filter criteria. If --tablet-alias is passed, none of the other filters (tablet-type, keyspace, shard, cell) may be passed, and tablets are looked up by tablet alias only. If --keyspace is passed, then all tablets in the keyspace are retrieved. The --shard flag may also be passed to further narrow the set of tablets to that <keyspace/shard>. Passing --shard without also passing --keyspace will fail. If --tablet-type is passed, only tablets of the specified type will be returned. Valid tablet types are: "%s". Passing --cell limits the set of tablets to those in the specified cells. The --cell flag accepts a CSV argument (e.g. --cell "c1,c2") and may be repeated (e.g. --cell "c1" --cell "c2"). Valid output formats are "awk" and "json".`, strings.Join(topoproto.MakeUniqueStringTypeList(topoproto.AllTabletTypes), "\", \"")), DisableFlagsInUseLine: true, Args: cobra.NoArgs, RunE: commandGetTablets, } // GetTabletVersion makes a GetVersion RPC to a vtctld. GetTabletVersion = &cobra.Command{ Use: "GetTabletVersion <alias>", Short: "Print the version of a tablet from its debug vars.", DisableFlagsInUseLine: true, Aliases: []string{"GetVersion"}, Args: cobra.ExactArgs(1), RunE: commandGetTabletVersion, } // PingTablet makes a PingTablet gRPC call to a vtctld. PingTablet = &cobra.Command{ Use: "PingTablet <alias>", Short: "Checks that the specified tablet is awake and responding to RPCs. This command can be blocked by other in-flight operations.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandPingTablet, } // RefreshState makes a RefreshState gRPC call to a vtctld. RefreshState = &cobra.Command{ Use: "RefreshState <alias>", Short: "Reloads the tablet record on the specified tablet.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandRefreshState, } // RefreshStateByShard makes a RefreshStateByShard gRPC call to a vtcld. RefreshStateByShard = &cobra.Command{ Use: "RefreshStateByShard [--cell <cell1> ...] <keyspace/shard>", Short: "Reloads the tablet record all tablets in the shard, optionally limited to the specified cells.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandRefreshStateByShard, } // RunHealthCheck makes a RunHealthCheck gRPC call to a vtctld. RunHealthCheck = &cobra.Command{ Use: "RunHealthCheck <tablet_alias>", Short: "Runs a healthcheck on the remote tablet.", DisableFlagsInUseLine: true, Aliases: []string{"RunHealthcheck"}, Args: cobra.ExactArgs(1), RunE: commandRunHealthCheck, } // SetWritable makes a SetWritable gRPC call to a vtctld. SetWritable = &cobra.Command{ Use: "SetWritable <alias> <true/false>", Short: "Sets the specified tablet as writable or read-only.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandSetWritable, } // SleepTablet makes a SleepTablet gRPC call to a vtctld. SleepTablet = &cobra.Command{ Use: "SleepTablet <alias> <duration>", Short: "Blocks the action queue on the specified tablet for the specified amount of time. This is typically used for testing.", Long: `SleepTablet <alias> <duration> Blocks the action queue on the specified tablet for the specified duration. This command is typically only used for testing. The duration is the amount of time that the action queue should be blocked. The value is a string that contains a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as “300ms” or “1h45m”. See the definition of the Go language’s ParseDuration[1] function for more details. Note that, in the SleepTablet implementation, the value should be positively-signed. [1]: https://pkg.go.dev/time#ParseDuration `, DisableFlagsInUseLine: true, Args: cobra.ExactArgs(2), RunE: commandSleepTablet, } // StartReplication makes a StartReplication gRPC call to a vtctld. StartReplication = &cobra.Command{ Use: "StartReplication <alias>", Short: "Starts replication on the specified tablet.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandStartReplication, } // StopReplication makes a StopReplication gRPC call to a vtctld. StopReplication = &cobra.Command{ Use: "StopReplication <alias>", Short: "Stops replication on the specified tablet.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandStopReplication, } )
var ( // Validate makes a Validate gRPC call to a vtctld. Validate = &cobra.Command{ Use: "Validate [--ping-tablets]", Short: "Validates that all nodes reachable from the global replication graph, as well as all tablets in discoverable cells, are consistent.", DisableFlagsInUseLine: true, Args: cobra.NoArgs, RunE: commandValidate, } // ValidateKeyspace makes a ValidateKeyspace gRPC call to a vtctld. ValidateKeyspace = &cobra.Command{ Use: "ValidateKeyspace [--ping-tablets] <keyspace>", Short: "Validates that all nodes reachable from the specified keyspace are consistent.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandValidateKeyspace, } // ValidateShard makes a ValidateShard gRPC call to a vtctld. ValidateShard = &cobra.Command{ Use: "ValidateShard [--ping-tablets] <keyspace/shard>", Short: "Validates that all nodes reachable from the specified shard are consistent.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandValidateShard, } )
var ( // GetVSchema makes a GetVSchema gRPC call to a vtctld. GetVSchema = &cobra.Command{ Use: "GetVSchema <keyspace>", Short: "Prints a JSON representation of a keyspace's topo record.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandGetVSchema, } // ApplyVSchema makes an ApplyVSchema gRPC call to a vtctld. ApplyVSchema = &cobra.Command{ Use: "ApplyVSchema {--vschema=<vschema> || --vschema-file=<vschema file> || --sql=<sql> || --sql-file=<sql file>} [--cells=c1,c2,...] [--skip-rebuild] [--dry-run] <keyspace>", Short: "Applies the VTGate routing schema to the provided keyspace. Shows the result after application.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandApplyVSchema, } )
var ( // GetTopologyPath makes a GetTopologyPath gRPC call to a vtctld. GetTopologyPath = &cobra.Command{ Use: "GetTopologyPath <path>", Short: "Gets the value associated with the particular path (key) in the topology server.", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandGetTopologyPath, } )
var ( // LegacyVtctlCommand provides a shim to make legacy ExecuteVtctlCommand // RPCs. This allows users to use a single binary to make RPCs against both // the new and old vtctld gRPC APIs. LegacyVtctlCommand = &cobra.Command{ Use: "LegacyVtctlCommand -- <command> [flags ...] [args ...]", Short: "Invoke a legacy vtctlclient command. Flag parsing is best effort.", DisableFlagsInUseLine: true, Args: cobra.ArbitraryArgs, RunE: func(cmd *cobra.Command, args []string) error { cli.FinishedParsing(cmd) return runLegacyCommand(args) }, Long: strings.TrimSpace(` LegacyVtctlCommand uses the legacy vtctl grpc client to make an ExecuteVtctlCommand rpc to a vtctld. This command exists to support a smooth transition of any scripts that relied on vtctlclient during the migration to the new vtctldclient, and will be removed, following the Vitess project's standard deprecation cycle, once all commands have been migrated to the new VtctldServer api. To see the list of available legacy commands, run "LegacyVtctlCommand -- help". Note that, as with the old client, this requires a running server, as the flag parsing and help/usage text generation, is done server-side. Also note that, in order to defer that flag parsing to the server side, you must use the double-dash ("--") after the LegacyVtctlCommand subcommand string, or the client-side flag parsing library we are using will attempt to parse those flags (and fail). `), Example: strings.TrimSpace(` LegacyVtctlCommand help # displays this help message LegacyVtctlCommand -- help # displays help for supported legacy vtctl commands # When using legacy command that take arguments, a double dash must be used # before the first flag argument, like in the first example. The double dash may # be used, however, at any point after the "LegacyVtctlCommand" string, as in # the second example. LegacyVtctlCommand AddCellInfo -- --server_address "localhost:1234" --root "/vitess/cell1" LegacyVtctlCommand -- AddCellInfo --server_address "localhost:5678" --root "/vitess/cell1"`), } )
var ( // UpdateThrottlerConfig makes a UpdateThrottlerConfig gRPC call to a vtctld. UpdateThrottlerConfig = &cobra.Command{ Use: "UpdateThrottlerConfig [--enable|--disable] [--threshold=<float64>] [--custom-query=<query>] [--check-as-check-self|--check-as-check-shard] [--throttle-app|unthrottle-app=<name>] [--throttle-app-ratio=<float, range [0..1]>] [--throttle-app-duration=<duration>] <keyspace>", Short: "Update the tablet throttler configuration for all tablets in the given keyspace (across all cells)", DisableFlagsInUseLine: true, Args: cobra.ExactArgs(1), RunE: commandUpdateThrottlerConfig, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.