Skip to content

Commit

Permalink
fix again
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Mou <[email protected]>
  • Loading branch information
Tristan1900 committed Oct 28, 2024
1 parent ac5a12b commit ffd6082
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 8 additions & 0 deletions br/cmd/br/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func runBackupCommand(command *cobra.Command, cmdName string) error {
command.SilenceUsage = false
return errors.Trace(err)
}
overrideDefaultBackupConfigIfNeeded(&cfg, command)

if err := metricsutil.RegisterMetricsForBR(cfg.PD, cfg.KeyspaceName); err != nil {
return errors.Trace(err)
Expand Down Expand Up @@ -211,3 +212,10 @@ func newTxnBackupCommand() *cobra.Command {
task.DefineTxnBackupFlags(command)
return command
}

func overrideDefaultBackupConfigIfNeeded(config *task.BackupConfig, cmd *cobra.Command) {
// override only if flag not set by user
if !cmd.Flags().Changed(task.FlagChecksum) {
config.Checksum = false
}
}
2 changes: 0 additions & 2 deletions br/pkg/task/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ func (cfg *BackupConfig) ParseFromFlags(flags *pflag.FlagSet, skipCommonConfig b
if err = cfg.Config.ParseFromFlags(flags); err != nil {
return errors.Trace(err)
}
// override common config specifically for backup use case
cfg.OverrideDefaultForBackup()
}

cfg.RemoveSchedulers, err = flags.GetBool(flagRemoveSchedulers)
Expand Down
8 changes: 4 additions & 4 deletions br/pkg/task/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const (
flagRateLimit = "ratelimit"
flagRateLimitUnit = "ratelimit-unit"
flagConcurrency = "concurrency"
flagChecksum = "checksum"
FlagChecksum = "checksum"
flagFilter = "filter"
flagCaseSensitive = "case-sensitive"
flagRemoveTiFlash = "remove-tiflash"
Expand Down Expand Up @@ -297,7 +297,7 @@ func DefineCommonFlags(flags *pflag.FlagSet) {
flags.Uint(flagChecksumConcurrency, variable.DefChecksumTableConcurrency, "The concurrency of checksumming in one table")

flags.Uint64(flagRateLimit, unlimited, "The rate limit of the task, MB/s per node")
flags.Bool(flagChecksum, true, "Run checksum at end of task")
flags.Bool(FlagChecksum, true, "Run checksum at end of task")
flags.Bool(flagRemoveTiFlash, true,
"Remove TiFlash replicas before backup or restore, for unsupported versions of TiFlash")

Expand Down Expand Up @@ -359,7 +359,7 @@ func DefineCommonFlags(flags *pflag.FlagSet) {

// HiddenFlagsForStream temporary hidden flags that stream cmd not support.
func HiddenFlagsForStream(flags *pflag.FlagSet) {
_ = flags.MarkHidden(flagChecksum)
_ = flags.MarkHidden(FlagChecksum)
_ = flags.MarkHidden(flagLoadStats)
_ = flags.MarkHidden(flagChecksumConcurrency)
_ = flags.MarkHidden(flagRateLimit)
Expand Down Expand Up @@ -609,7 +609,7 @@ func (cfg *Config) ParseFromFlags(flags *pflag.FlagSet) error {
return errors.Trace(err)
}

if cfg.Checksum, err = flags.GetBool(flagChecksum); err != nil {
if cfg.Checksum, err = flags.GetBool(FlagChecksum); err != nil {
return errors.Trace(err)
}
if cfg.ChecksumConcurrency, err = flags.GetUint(flagChecksumConcurrency); err != nil {
Expand Down

0 comments on commit ffd6082

Please sign in to comment.