Skip to content

Commit ae692e4

Browse files
committed
Refactor mysqlctld flags to follow standardized naming
Signed-off-by: mounicasruthi <[email protected]>
1 parent d9380c1 commit ae692e4

File tree

17 files changed

+37
-26
lines changed

17 files changed

+37
-26
lines changed

examples/compose/vttablet-up.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ rm -rf $VTDATAROOT/$tablet_dir/{mysql.sock,mysql.sock.lock}
9595

9696
# Create mysql instances
9797
# Do not create mysql instance for primary if connecting to external mysql database
98+
9899
#TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation
99100
if [[ $tablet_role != "externalprimary" ]]; then
100101
echo "Initing mysql for tablet: $uid role: $role external: $external.. "

go/cmd/mysqlctl/command/init.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/spf13/cobra"
2525

2626
"vitess.io/vitess/go/vt/mysqlctl"
27+
"vitess.io/vitess/go/vt/utils"
2728
)
2829

2930
var Init = &cobra.Command{
@@ -64,8 +65,8 @@ func commandInit(cmd *cobra.Command, args []string) error {
6465
}
6566

6667
func init() {
67-
Init.Flags().DurationVar(&initArgs.WaitTime, "wait_time", initArgs.WaitTime, "How long to wait for mysqld startup.")
68-
Init.Flags().StringVar(&initArgs.InitDbSQLFile, "init_db_sql_file", initArgs.InitDbSQLFile, "Path to .sql file to run after mysqld initiliaztion.")
68+
utils.SetFlagDurationVar(Init.Flags(), &initArgs.WaitTime, "wait-time", initArgs.WaitTime, "How long to wait for mysqld startup.")
69+
utils.SetFlagStringVar(Init.Flags(), &initArgs.InitDbSQLFile, "init-db-sql-file", initArgs.InitDbSQLFile, "Path to .sql file to run after mysqld initiliaztion.")
6970

7071
Root.AddCommand(Init)
7172
}

go/cmd/mysqlctl/command/shutdown.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ import (
2424
"github.com/spf13/cobra"
2525

2626
"vitess.io/vitess/go/vt/mysqlctl"
27+
"vitess.io/vitess/go/vt/utils"
2728
)
2829

2930
var Shutdown = &cobra.Command{
3031
Use: "shutdown",
3132
Short: "Shuts down mysqld, without removing any files.",
3233
Long: "Stop a `mysqld` instance that was previously started with `init` or `start`.\n\n" +
33-
"For large `mysqld` instances, you may need to extend the `wait_time` to shutdown cleanly.",
34+
"For large `mysqld` instances, you may need to extend the `wait-time` to shutdown cleanly.",
3435
Example: `mysqlctl --tablet-uid 101 --alsologtostderr shutdown`,
3536
Args: cobra.NoArgs,
3637
RunE: commandShutdown,
@@ -59,7 +60,7 @@ func commandShutdown(cmd *cobra.Command, args []string) error {
5960
}
6061

6162
func init() {
62-
Shutdown.Flags().DurationVar(&shutdownArgs.WaitTime, "wait_time", shutdownArgs.WaitTime, "How long to wait for mysqld shutdown.")
63+
utils.SetFlagDurationVar(Shutdown.Flags(), &shutdownArgs.WaitTime, "wait-time", shutdownArgs.WaitTime, "How long to wait for mysqld shutdown.")
6364

6465
Root.AddCommand(Shutdown)
6566
}

go/cmd/mysqlctl/command/start.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"vitess.io/vitess/go/flagutil"
2727
"vitess.io/vitess/go/vt/mysqlctl"
28+
"vitess.io/vitess/go/vt/utils"
2829
)
2930

3031
var Start = &cobra.Command{
@@ -60,7 +61,7 @@ func commandStart(cmd *cobra.Command, args []string) error {
6061
}
6162

6263
func init() {
63-
Start.Flags().DurationVar(&startArgs.WaitTime, "wait_time", startArgs.WaitTime, "How long to wait for mysqld startup.")
64+
utils.SetFlagDurationVar(Start.Flags(), &startArgs.WaitTime, "wait-time", startArgs.WaitTime, "How long to wait for mysqld startup.")
6465
Start.Flags().Var(&startArgs.MySQLdArgs, "mysqld_args", "List of comma-separated flags to pass additionally to mysqld.")
6566

6667
Root.AddCommand(Start)

go/cmd/mysqlctl/command/teardown.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/spf13/cobra"
2525

2626
"vitess.io/vitess/go/vt/mysqlctl"
27+
"vitess.io/vitess/go/vt/utils"
2728
)
2829

2930
var Teardown = &cobra.Command{
@@ -62,7 +63,7 @@ func commandTeardown(cmd *cobra.Command, args []string) error {
6263
}
6364

6465
func init() {
65-
Teardown.Flags().DurationVar(&teardownArgs.WaitTime, "wait_time", teardownArgs.WaitTime, "How long to wait for mysqld shutdown.")
66+
utils.SetFlagDurationVar(Teardown.Flags(), &teardownArgs.WaitTime, "wait-time", teardownArgs.WaitTime, "How long to wait for mysqld shutdown.")
6667
Teardown.Flags().BoolVarP(&teardownArgs.Force, "force", "f", teardownArgs.Force, "Remove the root directory even if mysqld shutdown fails.")
6768

6869
Root.AddCommand(Teardown)

go/cmd/mysqlctld/cli/mysqlctld.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var (
6666
--log_dir=${VTDATAROOT}/logs \
6767
--tablet-uid=100 \
6868
--mysql-port=17100 \
69-
--socket_file=/path/to/socket_file`,
69+
--socket-file=/path/to/socket-file`,
7070
Args: cobra.NoArgs,
7171
Version: servenv.AppVersion.String(),
7272
PreRunE: servenv.CobraPreRunE,
@@ -95,8 +95,8 @@ func init() {
9595
utils.SetFlagIntVar(Main.Flags(), &mysqlPort, "mysql-port", mysqlPort, "MySQL port")
9696
utils.SetFlagUint32Var(Main.Flags(), &tabletUID, "tablet-uid", tabletUID, "Tablet UID")
9797
utils.SetFlagStringVar(Main.Flags(), &mysqlSocket, "mysql-socket", mysqlSocket, "Path to the mysqld socket file")
98-
Main.Flags().DurationVar(&waitTime, "wait_time", waitTime, "How long to wait for mysqld startup")
99-
Main.Flags().StringVar(&initDBSQLFile, "init_db_sql_file", initDBSQLFile, "Path to .sql file to run after mysqld initialization")
98+
utils.SetFlagDurationVar(Main.Flags(), &waitTime, "wait-time", waitTime, "How long to wait for mysqld startup")
99+
utils.SetFlagStringVar(Main.Flags(), &initDBSQLFile, "init-db-sql-file", initDBSQLFile, "Path to .sql file to run after mysqld initialization")
100100
Main.Flags().DurationVar(&shutdownWaitTime, "shutdown-wait-time", shutdownWaitTime, "How long to wait for mysqld shutdown")
101101

102102
acl.RegisterFlags(Main.Flags())

go/cmd/vtbackup/cli/vtbackup.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func init() {
204204
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.")
205205
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.")
206206
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")
207-
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).")
207+
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).")
208208
Main.Flags().BoolVar(&allowFirstBackup, "allow_first_backup", allowFirstBackup, "Allow this job to take the first backup of an existing shard.")
209209
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.")
210210
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() {
221221
utils.SetFlagStringVar(Main.Flags(), &mysqlSocket, "mysql-socket", mysqlSocket, "Path to the mysqld socket file")
222222
Main.Flags().DurationVar(&mysqlTimeout, "mysql_timeout", mysqlTimeout, "how long to wait for mysqld startup")
223223
Main.Flags().DurationVar(&mysqlShutdownTimeout, "mysql-shutdown-timeout", mysqlShutdownTimeout, "how long to wait for mysqld shutdown")
224-
Main.Flags().StringVar(&initDBSQLFile, "init_db_sql_file", initDBSQLFile, "path to .sql file to run after mysql_install_db")
224+
utils.SetFlagStringVar(Main.Flags(), &initDBSQLFile, "init-db-sql-file", initDBSQLFile, "path to .sql file to run after mysql_install_db")
225225
Main.Flags().BoolVar(&detachedMode, "detach", detachedMode, "detached mode - run backups detached from the terminal")
226226
Main.Flags().DurationVar(&keepAliveTimeout, "keep-alive-timeout", keepAliveTimeout, "Wait until timeout elapses after a successful backup before shutting down.")
227227
Main.Flags().BoolVar(&disableRedoLog, "disable-redo-log", disableRedoLog, "Disable InnoDB redo log during replication-from-primary phase of backup.")

go/cmd/vtctl/vtctl.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"vitess.io/vitess/go/vt/logutil"
3737
"vitess.io/vitess/go/vt/servenv"
3838
"vitess.io/vitess/go/vt/topo"
39+
"vitess.io/vitess/go/vt/utils"
3940
"vitess.io/vitess/go/vt/vtctl"
4041
"vitess.io/vitess/go/vt/vtctl/grpcvtctldserver"
4142
"vitess.io/vitess/go/vt/vtctl/localvtctldclient"
@@ -86,7 +87,7 @@ func init() {
8687
vtctl.PrintAllCommands(logger)
8788
}
8889

89-
fs.DurationVar(&waitTime, "wait-time", waitTime, "time to wait on an action")
90+
utils.SetFlagDurationVar(fs, &waitTime, "wait-time", waitTime, "time to wait on an action")
9091
fs.BoolVar(&detachedMode, "detach", detachedMode, "detached mode - run vtcl detached from the terminal")
9192

9293
acl.RegisterFlags(fs)

go/flags/endtoend/mysqlctl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Flags:
8686
--replication-connect-retry duration how long to wait in between replica reconnect attempts. Only precise to the second. (default 10s)
8787
--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)
8888
--service-map strings comma separated list of services to enable (or disable if prefixed with '-') Example: grpc-queryservice
89-
--socket_file string Local unix socket file to listen on
89+
--socket-file string Local unix socket file to listen on
9090
--stderrthreshold severityFlag logs at or above this threshold go to stderr (default 1)
9191
--table-refresh-interval int interval in milliseconds to refresh tables in status page with refreshRequired class
9292
--tablet-dir string The directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid.

go/flags/endtoend/mysqlctld.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mysqlctld \
1616
--log_dir=${VTDATAROOT}/logs \
1717
--tablet-uid=100 \
1818
--mysql-port=17100 \
19-
--socket_file=/path/to/socket_file
19+
--socket-file=/path/to/socket-file
2020

2121
Flags:
2222
--alsologtostderr log to standard error as well as files
@@ -89,7 +89,7 @@ Flags:
8989
--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)
9090
--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)
9191
-h, --help help for mysqlctld
92-
--init_db_sql_file string Path to .sql file to run after mysqld initialization
92+
--init-db-sql-file string Path to .sql file to run after mysqld initialization
9393
--keep-logs duration keep logs for this long (using ctime) (zero to keep forever)
9494
--keep-logs-by-mtime duration keep logs for this long (using mtime) (zero to keep forever)
9595
--lameduck-period duration keep running at least this long after SIGTERM before stopping (default 50ms)
@@ -116,12 +116,12 @@ Flags:
116116
--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)
117117
--service-map strings comma separated list of services to enable (or disable if prefixed with '-') Example: grpc-queryservice
118118
--shutdown-wait-time duration How long to wait for mysqld shutdown (default 5m0s)
119-
--socket_file string Local unix socket file to listen on
119+
--socket-file string Local unix socket file to listen on
120120
--stderrthreshold severityFlag logs at or above this threshold go to stderr (default 1)
121121
--table-refresh-interval int interval in milliseconds to refresh tables in status page with refreshRequired class
122122
--tablet-dir string The directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid.
123123
--tablet-uid uint32 Tablet UID (default 41983)
124124
--v Level log level for V logs
125125
-v, --version print binary version
126126
--vmodule vModuleFlag comma-separated list of pattern=N settings for file-filtered logging
127-
--wait_time duration How long to wait for mysqld startup (default 5m0s)
127+
--wait-time duration How long to wait for mysqld startup (default 5m0s)

0 commit comments

Comments
 (0)