diff --git a/go/cmd/mysqlctl/command/init.go b/go/cmd/mysqlctl/command/init.go index eac1c87ff4e..68e2c020b95 100644 --- a/go/cmd/mysqlctl/command/init.go +++ b/go/cmd/mysqlctl/command/init.go @@ -24,6 +24,7 @@ import ( "github.com/spf13/cobra" "vitess.io/vitess/go/vt/mysqlctl" + "vitess.io/vitess/go/vt/utils" ) var Init = &cobra.Command{ @@ -64,8 +65,8 @@ func commandInit(cmd *cobra.Command, args []string) error { } func init() { - Init.Flags().DurationVar(&initArgs.WaitTime, "wait_time", initArgs.WaitTime, "How long to wait for mysqld startup.") - Init.Flags().StringVar(&initArgs.InitDbSQLFile, "init_db_sql_file", initArgs.InitDbSQLFile, "Path to .sql file to run after mysqld initiliaztion.") + utils.SetFlagDurationVar(Init.Flags(), &initArgs.WaitTime, "wait-time", initArgs.WaitTime, "How long to wait for mysqld startup.") + utils.SetFlagStringVar(Init.Flags(), &initArgs.InitDbSQLFile, "init-db-sql-file", initArgs.InitDbSQLFile, "Path to .sql file to run after mysqld initiliaztion.") Root.AddCommand(Init) } diff --git a/go/cmd/mysqlctl/command/shutdown.go b/go/cmd/mysqlctl/command/shutdown.go index 725fc061b88..9f30088dcb4 100644 --- a/go/cmd/mysqlctl/command/shutdown.go +++ b/go/cmd/mysqlctl/command/shutdown.go @@ -24,13 +24,14 @@ import ( "github.com/spf13/cobra" "vitess.io/vitess/go/vt/mysqlctl" + "vitess.io/vitess/go/vt/utils" ) var Shutdown = &cobra.Command{ Use: "shutdown", Short: "Shuts down mysqld, without removing any files.", Long: "Stop a `mysqld` instance that was previously started with `init` or `start`.\n\n" + - "For large `mysqld` instances, you may need to extend the `wait_time` to shutdown cleanly.", + "For large `mysqld` instances, you may need to extend the `wait-time` to shutdown cleanly.", Example: `mysqlctl --tablet-uid 101 --alsologtostderr shutdown`, Args: cobra.NoArgs, RunE: commandShutdown, @@ -59,7 +60,7 @@ func commandShutdown(cmd *cobra.Command, args []string) error { } func init() { - Shutdown.Flags().DurationVar(&shutdownArgs.WaitTime, "wait_time", shutdownArgs.WaitTime, "How long to wait for mysqld shutdown.") + utils.SetFlagDurationVar(Shutdown.Flags(), &shutdownArgs.WaitTime, "wait-time", shutdownArgs.WaitTime, "How long to wait for mysqld shutdown.") Root.AddCommand(Shutdown) } diff --git a/go/cmd/mysqlctl/command/start.go b/go/cmd/mysqlctl/command/start.go index 662a110c8cd..872443fe2e6 100644 --- a/go/cmd/mysqlctl/command/start.go +++ b/go/cmd/mysqlctl/command/start.go @@ -25,6 +25,7 @@ import ( "vitess.io/vitess/go/flagutil" "vitess.io/vitess/go/vt/mysqlctl" + "vitess.io/vitess/go/vt/utils" ) var Start = &cobra.Command{ @@ -60,7 +61,7 @@ func commandStart(cmd *cobra.Command, args []string) error { } func init() { - Start.Flags().DurationVar(&startArgs.WaitTime, "wait_time", startArgs.WaitTime, "How long to wait for mysqld startup.") + utils.SetFlagDurationVar(Start.Flags(), &startArgs.WaitTime, "wait-time", startArgs.WaitTime, "How long to wait for mysqld startup.") Start.Flags().Var(&startArgs.MySQLdArgs, "mysqld_args", "List of comma-separated flags to pass additionally to mysqld.") Root.AddCommand(Start) diff --git a/go/cmd/mysqlctl/command/teardown.go b/go/cmd/mysqlctl/command/teardown.go index 77a653bd030..a9bd659916c 100644 --- a/go/cmd/mysqlctl/command/teardown.go +++ b/go/cmd/mysqlctl/command/teardown.go @@ -24,6 +24,7 @@ import ( "github.com/spf13/cobra" "vitess.io/vitess/go/vt/mysqlctl" + "vitess.io/vitess/go/vt/utils" ) var Teardown = &cobra.Command{ @@ -62,7 +63,7 @@ func commandTeardown(cmd *cobra.Command, args []string) error { } func init() { - Teardown.Flags().DurationVar(&teardownArgs.WaitTime, "wait_time", teardownArgs.WaitTime, "How long to wait for mysqld shutdown.") + utils.SetFlagDurationVar(Teardown.Flags(), &teardownArgs.WaitTime, "wait-time", teardownArgs.WaitTime, "How long to wait for mysqld shutdown.") Teardown.Flags().BoolVarP(&teardownArgs.Force, "force", "f", teardownArgs.Force, "Remove the root directory even if mysqld shutdown fails.") Root.AddCommand(Teardown) diff --git a/go/cmd/mysqlctld/cli/mysqlctld.go b/go/cmd/mysqlctld/cli/mysqlctld.go index 94861edf27c..e4f63b9c57f 100644 --- a/go/cmd/mysqlctld/cli/mysqlctld.go +++ b/go/cmd/mysqlctld/cli/mysqlctld.go @@ -66,7 +66,7 @@ var ( --log_dir=${VTDATAROOT}/logs \ --tablet-uid=100 \ --mysql-port=17100 \ - --socket_file=/path/to/socket_file`, + --socket-file=/path/to/socket-file`, Args: cobra.NoArgs, Version: servenv.AppVersion.String(), PreRunE: servenv.CobraPreRunE, @@ -95,8 +95,8 @@ func init() { utils.SetFlagIntVar(Main.Flags(), &mysqlPort, "mysql-port", mysqlPort, "MySQL port") utils.SetFlagUint32Var(Main.Flags(), &tabletUID, "tablet-uid", tabletUID, "Tablet UID") utils.SetFlagStringVar(Main.Flags(), &mysqlSocket, "mysql-socket", mysqlSocket, "Path to the mysqld socket file") - Main.Flags().DurationVar(&waitTime, "wait_time", waitTime, "How long to wait for mysqld startup") - Main.Flags().StringVar(&initDBSQLFile, "init_db_sql_file", initDBSQLFile, "Path to .sql file to run after mysqld initialization") + utils.SetFlagDurationVar(Main.Flags(), &waitTime, "wait-time", waitTime, "How long to wait for mysqld startup") + utils.SetFlagStringVar(Main.Flags(), &initDBSQLFile, "init-db-sql-file", initDBSQLFile, "Path to .sql file to run after mysqld initialization") Main.Flags().DurationVar(&shutdownWaitTime, "shutdown-wait-time", shutdownWaitTime, "How long to wait for mysqld shutdown") acl.RegisterFlags(Main.Flags()) diff --git a/go/cmd/vtbackup/cli/vtbackup.go b/go/cmd/vtbackup/cli/vtbackup.go index a4e7fba9798..2f2654c0586 100644 --- a/go/cmd/vtbackup/cli/vtbackup.go +++ b/go/cmd/vtbackup/cli/vtbackup.go @@ -204,7 +204,7 @@ func init() { Main.Flags().DurationVar(&minBackupInterval, "min_backup_interval", minBackupInterval, "Only take a new backup if it's been at least this long since the most recent backup.") Main.Flags().DurationVar(&minRetentionTime, "min_retention_time", minRetentionTime, "Keep each old backup for at least this long before removing it. Set to 0 to disable pruning of old backups.") Main.Flags().IntVar(&minRetentionCount, "min_retention_count", minRetentionCount, "Always keep at least this many of the most recent backups in this backup storage location, even if some are older than the min_retention_time. This must be at least 1 since a backup must always exist to allow new backups to be made") - Main.Flags().BoolVar(&initialBackup, "initial_backup", initialBackup, "Instead of restoring from backup, initialize an empty database with the provided init_db_sql_file and upload a backup of that for the shard, if the shard has no backups yet. This can be used to seed a brand new shard with an initial, empty backup. If any backups already exist for the shard, this will be considered a successful no-op. This can only be done before the shard exists in topology (i.e. before any tablets are deployed).") + Main.Flags().BoolVar(&initialBackup, "initial_backup", initialBackup, "Instead of restoring from backup, initialize an empty database with the provided init-db-sql-file and upload a backup of that for the shard, if the shard has no backups yet. This can be used to seed a brand new shard with an initial, empty backup. If any backups already exist for the shard, this will be considered a successful no-op. This can only be done before the shard exists in topology (i.e. before any tablets are deployed).") Main.Flags().BoolVar(&allowFirstBackup, "allow_first_backup", allowFirstBackup, "Allow this job to take the first backup of an existing shard.") Main.Flags().BoolVar(&restartBeforeBackup, "restart_before_backup", restartBeforeBackup, "Perform a mysqld clean/full restart after applying binlogs, but before taking the backup. Only makes sense to work around xtrabackup bugs.") Main.Flags().BoolVar(&upgradeSafe, "upgrade-safe", upgradeSafe, "Whether to use innodb_fast_shutdown=0 for the backup so it is safe to use for MySQL upgrades.") @@ -221,7 +221,7 @@ func init() { utils.SetFlagStringVar(Main.Flags(), &mysqlSocket, "mysql-socket", mysqlSocket, "Path to the mysqld socket file") Main.Flags().DurationVar(&mysqlTimeout, "mysql_timeout", mysqlTimeout, "how long to wait for mysqld startup") Main.Flags().DurationVar(&mysqlShutdownTimeout, "mysql-shutdown-timeout", mysqlShutdownTimeout, "how long to wait for mysqld shutdown") - Main.Flags().StringVar(&initDBSQLFile, "init_db_sql_file", initDBSQLFile, "path to .sql file to run after mysql_install_db") + utils.SetFlagStringVar(Main.Flags(), &initDBSQLFile, "init-db-sql-file", initDBSQLFile, "path to .sql file to run after mysql_install_db") Main.Flags().BoolVar(&detachedMode, "detach", detachedMode, "detached mode - run backups detached from the terminal") Main.Flags().DurationVar(&keepAliveTimeout, "keep-alive-timeout", keepAliveTimeout, "Wait until timeout elapses after a successful backup before shutting down.") Main.Flags().BoolVar(&disableRedoLog, "disable-redo-log", disableRedoLog, "Disable InnoDB redo log during replication-from-primary phase of backup.") diff --git a/go/cmd/vtctl/vtctl.go b/go/cmd/vtctl/vtctl.go index ba84369620a..78fd403deec 100644 --- a/go/cmd/vtctl/vtctl.go +++ b/go/cmd/vtctl/vtctl.go @@ -36,6 +36,7 @@ import ( "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/topo" + "vitess.io/vitess/go/vt/utils" "vitess.io/vitess/go/vt/vtctl" "vitess.io/vitess/go/vt/vtctl/grpcvtctldserver" "vitess.io/vitess/go/vt/vtctl/localvtctldclient" @@ -86,7 +87,7 @@ func init() { vtctl.PrintAllCommands(logger) } - fs.DurationVar(&waitTime, "wait-time", waitTime, "time to wait on an action") + utils.SetFlagDurationVar(fs, &waitTime, "wait-time", waitTime, "time to wait on an action") fs.BoolVar(&detachedMode, "detach", detachedMode, "detached mode - run vtcl detached from the terminal") acl.RegisterFlags(fs) diff --git a/go/flags/endtoend/mysqlctl.txt b/go/flags/endtoend/mysqlctl.txt index 8d0890887c5..c3dc4b920ff 100644 --- a/go/flags/endtoend/mysqlctl.txt +++ b/go/flags/endtoend/mysqlctl.txt @@ -86,7 +86,7 @@ Flags: --replication-connect-retry duration how long to wait in between replica reconnect attempts. Only precise to the second. (default 10s) --security-policy string the name of a registered security policy to use for controlling access to URLs - empty means allow all for anyone (built-in policies: deny-all, read-only) --service-map strings comma separated list of services to enable (or disable if prefixed with '-') Example: grpc-queryservice - --socket_file string Local unix socket file to listen on + --socket-file string Local unix socket file to listen on --stderrthreshold severityFlag logs at or above this threshold go to stderr (default 1) --table-refresh-interval int interval in milliseconds to refresh tables in status page with refreshRequired class --tablet-dir string The directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid. diff --git a/go/flags/endtoend/mysqlctld.txt b/go/flags/endtoend/mysqlctld.txt index a0d3edf6ef0..e728e1561d2 100644 --- a/go/flags/endtoend/mysqlctld.txt +++ b/go/flags/endtoend/mysqlctld.txt @@ -16,7 +16,7 @@ mysqlctld \ --log_dir=${VTDATAROOT}/logs \ --tablet-uid=100 \ --mysql-port=17100 \ - --socket_file=/path/to/socket_file + --socket-file=/path/to/socket-file Flags: --alsologtostderr log to standard error as well as files @@ -89,7 +89,7 @@ Flags: --grpc-server-keepalive-time duration After a duration of this time, if the server doesn't see any activity, it pings the client to see if the transport is still alive. (default 10s) --grpc-server-keepalive-timeout duration After having pinged for keepalive check, the server waits for a duration of Timeout and if no activity is seen even after that the connection is closed. (default 10s) -h, --help help for mysqlctld - --init_db_sql_file string Path to .sql file to run after mysqld initialization + --init-db-sql-file string Path to .sql file to run after mysqld initialization --keep-logs duration keep logs for this long (using ctime) (zero to keep forever) --keep-logs-by-mtime duration keep logs for this long (using mtime) (zero to keep forever) --lameduck-period duration keep running at least this long after SIGTERM before stopping (default 50ms) @@ -116,7 +116,7 @@ Flags: --security-policy string the name of a registered security policy to use for controlling access to URLs - empty means allow all for anyone (built-in policies: deny-all, read-only) --service-map strings comma separated list of services to enable (or disable if prefixed with '-') Example: grpc-queryservice --shutdown-wait-time duration How long to wait for mysqld shutdown (default 5m0s) - --socket_file string Local unix socket file to listen on + --socket-file string Local unix socket file to listen on --stderrthreshold severityFlag logs at or above this threshold go to stderr (default 1) --table-refresh-interval int interval in milliseconds to refresh tables in status page with refreshRequired class --tablet-dir string The directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid. @@ -124,4 +124,4 @@ Flags: --v Level log level for V logs -v, --version print binary version --vmodule vModuleFlag comma-separated list of pattern=N settings for file-filtered logging - --wait_time duration How long to wait for mysqld startup (default 5m0s) + --wait-time duration How long to wait for mysqld startup (default 5m0s) diff --git a/go/flags/endtoend/vtbackup.txt b/go/flags/endtoend/vtbackup.txt index 0481df556d5..f6ca6b679cd 100644 --- a/go/flags/endtoend/vtbackup.txt +++ b/go/flags/endtoend/vtbackup.txt @@ -147,10 +147,10 @@ Flags: -h, --help help for vtbackup --incremental_from_pos string Position, or name of backup from which to create an incremental backup. Default: empty. If given, then this backup becomes an incremental backup from given position or given backup. If value is 'auto', this backup will be taken from the last successful backup position. --init-db-name-override string (init parameter) override the name of the db used by vttablet + --init-db-sql-file string path to .sql file to run after mysql_install_db --init-keyspace string (init parameter) keyspace to use for this tablet --init-shard string (init parameter) shard to use for this tablet - --init_db_sql_file string path to .sql file to run after mysql_install_db - --initial_backup Instead of restoring from backup, initialize an empty database with the provided init_db_sql_file and upload a backup of that for the shard, if the shard has no backups yet. This can be used to seed a brand new shard with an initial, empty backup. If any backups already exist for the shard, this will be considered a successful no-op. This can only be done before the shard exists in topology (i.e. before any tablets are deployed). + --initial_backup Instead of restoring from backup, initialize an empty database with the provided init-db-sql-file and upload a backup of that for the shard, if the shard has no backups yet. This can be used to seed a brand new shard with an initial, empty backup. If any backups already exist for the shard, this will be considered a successful no-op. This can only be done before the shard exists in topology (i.e. before any tablets are deployed). --keep-alive-timeout duration Wait until timeout elapses after a successful backup before shutting down. --keep-logs duration keep logs for this long (using ctime) (zero to keep forever) --keep-logs-by-mtime duration keep logs for this long (using mtime) (zero to keep forever) diff --git a/go/test/endtoend/cluster/mysqlctl_process.go b/go/test/endtoend/cluster/mysqlctl_process.go index 397d0631788..ca741c2814c 100644 --- a/go/test/endtoend/cluster/mysqlctl_process.go +++ b/go/test/endtoend/cluster/mysqlctl_process.go @@ -54,7 +54,7 @@ type MysqlctlProcess struct { // InitDb executes mysqlctl command to add cell info func (mysqlctl *MysqlctlProcess) InitDb() (err error) { args := []string{"--log_dir", mysqlctl.LogDirectory, - //TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation + //todo: Remove underscore(_) flags in v25, replace them with dashed(-) notation "--tablet_uid", fmt.Sprintf("%d", mysqlctl.TabletUID), "--mysql_port", fmt.Sprintf("%d", mysqlctl.MySQLPort), "init", @@ -63,6 +63,7 @@ func (mysqlctl *MysqlctlProcess) InitDb() (err error) { args = append(args, "--") } + //TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation args = append(args, "--init_db_sql_file", mysqlctl.InitDBFile) if *isCoverage { args = append([]string{"--test.coverprofile=" + getCoveragePath("mysql-initdb.out"), "--test.v"}, args...) @@ -156,7 +157,7 @@ ssl_key={{.ServerKey}} if mysqlctl.MajorVersion < 18 { tmpProcess.Args = append(tmpProcess.Args, "--") } - + //TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation tmpProcess.Args = append(tmpProcess.Args, "--init_db_sql_file", mysqlctl.InitDBFile) } else { tmpProcess.Args = append(tmpProcess.Args, "start") diff --git a/go/test/endtoend/cluster/mysqlctld_process.go b/go/test/endtoend/cluster/mysqlctld_process.go index 003df184bb6..8a25b7bcffe 100644 --- a/go/test/endtoend/cluster/mysqlctld_process.go +++ b/go/test/endtoend/cluster/mysqlctld_process.go @@ -80,6 +80,7 @@ func (mysqlctld *MysqlctldProcess) Start() error { "--mysql_port", fmt.Sprintf("%d", mysqlctld.MySQLPort), } if mysqlctld.SocketFile != "" { + //TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation args = append(args, "--socket_file", mysqlctld.SocketFile) } tempProcess := exec.Command( @@ -91,6 +92,7 @@ func (mysqlctld *MysqlctldProcess) Start() error { if mysqlctld.InitMysql { tempProcess.Args = append(tempProcess.Args, + //TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation "--init_db_sql_file", mysqlctld.InitDBFile) } diff --git a/go/test/endtoend/cluster/vtbackup_process.go b/go/test/endtoend/cluster/vtbackup_process.go index 6e3e10a444b..77ea3c2b6a7 100644 --- a/go/test/endtoend/cluster/vtbackup_process.go +++ b/go/test/endtoend/cluster/vtbackup_process.go @@ -65,7 +65,7 @@ func (vtbackup *VtbackupProcess) Setup() (err error) { //initDBfile is required to run vtbackup "--mysql-port": fmt.Sprintf("%d", vtbackup.MysqlPort), - "--init_db_sql_file": vtbackup.initDBfile, + "--init-db-sql-file": vtbackup.initDBfile, "--init-keyspace": vtbackup.Keyspace, "--init-shard": vtbackup.Shard, @@ -78,6 +78,7 @@ func (vtbackup *VtbackupProcess) Setup() (err error) { utils.SetFlagVariantsForTests(flags, "--topo-global-server-address", vtbackup.TopoGlobalAddress) utils.SetFlagVariantsForTests(flags, "--topo-global-root", vtbackup.TopoGlobalRoot) utils.SetFlagVariantsForTests(flags, "--mysql-port", fmt.Sprintf("%d", vtbackup.MysqlPort)) + utils.SetFlagVariantsForTests(flags, "--init-db-sql-file", vtbackup.initDBfile) utils.SetFlagVariantsForTests(flags, "--init-keyspace", vtbackup.Keyspace) utils.SetFlagVariantsForTests(flags, "--init-shard", vtbackup.Shard) utils.SetFlagVariantsForTests(flags, "--backup-storage-implementation", vtbackup.BackupStorageImplementation) diff --git a/go/vt/mysqlctl/mysqld.go b/go/vt/mysqlctl/mysqld.go index def10c3a1ea..7d964ef3c89 100644 --- a/go/vt/mysqlctl/mysqld.go +++ b/go/vt/mysqlctl/mysqld.go @@ -802,15 +802,15 @@ func (mysqld *Mysqld) Init(ctx context.Context, cnf *Mycnf, initDBSQLFile string // else, user specified an init db file sqlFile, err := os.Open(initDBSQLFile) if err != nil { - return fmt.Errorf("can't open init_db_sql_file (%v): %v", initDBSQLFile, err) + return fmt.Errorf("can't open init-db-sql-file (%v): %v", initDBSQLFile, err) } defer sqlFile.Close() script, err := io.ReadAll(sqlFile) if err != nil { - return fmt.Errorf("can't read init_db_sql_file (%v): %v", initDBSQLFile, err) + return fmt.Errorf("can't read init-db-sql-file (%v): %v", initDBSQLFile, err) } if err := mysqld.executeMysqlScript(ctx, params, string(script)); err != nil { - return fmt.Errorf("can't run init_db_sql_file (%v): %v", initDBSQLFile, err) + return fmt.Errorf("can't run init-db-sql-file (%v): %v", initDBSQLFile, err) } return nil } diff --git a/go/vt/servenv/unix_socket.go b/go/vt/servenv/unix_socket.go index 64b21537bfa..059b38458bd 100644 --- a/go/vt/servenv/unix_socket.go +++ b/go/vt/servenv/unix_socket.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/pflag" "vitess.io/vitess/go/vt/log" + "vitess.io/vitess/go/vt/utils" ) var ( @@ -59,6 +60,6 @@ func serveSocketFile() { // to a socket. This needs to be called before flags are parsed. func RegisterDefaultSocketFileFlags() { OnParse(func(fs *pflag.FlagSet) { - fs.StringVar(&socketFile, "socket_file", socketFile, "Local unix socket file to listen on") + utils.SetFlagStringVar(fs, &socketFile, "socket-file", socketFile, "Local unix socket file to listen on") }) } diff --git a/go/vt/vttest/mysqlctl.go b/go/vt/vttest/mysqlctl.go index 751da56f3d8..ab7d21a0894 100644 --- a/go/vt/vttest/mysqlctl.go +++ b/go/vt/vttest/mysqlctl.go @@ -67,7 +67,7 @@ func (ctl *Mysqlctl) Setup() error { "--tablet-uid", fmt.Sprintf("%d", ctl.UID), "--mysql-port", fmt.Sprintf("%d", ctl.Port), "init", - "--init_db_sql_file", ctl.InitFile, + "--init-db-sql-file", ctl.InitFile, ) myCnf := strings.Join(ctl.MyCnf, ":")