Skip to content

Commit

Permalink
config: tototally remove the deprecated field in pd server config
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <[email protected]>
  • Loading branch information
nolouch committed Jan 8, 2025
1 parent 973234d commit b888156
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
26 changes: 4 additions & 22 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"math"
"net/url"
"os"
"path/filepath"
Expand Down Expand Up @@ -507,9 +506,6 @@ type PDServerConfig struct {
MetricStorage string `toml:"metric-storage" json:"metric-storage"`
// There are some values supported: "auto", "none", or a specific address, default: "auto"
DashboardAddress string `toml:"dashboard-address" json:"dashboard-address"`
// TraceRegionFlow the option to update flow information of regions.
// WARN: TraceRegionFlow is deprecated.
TraceRegionFlow bool `toml:"trace-region-flow" json:"trace-region-flow,string,omitempty"`
// FlowRoundByDigit used to discretization processing flow information.
FlowRoundByDigit int `toml:"flow-round-by-digit" json:"flow-round-by-digit"`
// MinResolvedTSPersistenceInterval is the interval to save the min resolved ts.
Expand Down Expand Up @@ -581,29 +577,15 @@ func (c *PDServerConfig) adjust(meta *configutil.ConfigMetaData) error {

func (c *PDServerConfig) migrateConfigurationFromFile(meta *configutil.ConfigMetaData) error {

Check failure on line 578 in server/config/config.go

View workflow job for this annotation

GitHub Actions / statics

unused-receiver: method receiver 'c' is not referenced in method's body, consider removing or renaming it as _ (revive)
oldName, newName := "trace-region-flow", "flow-round-by-digit"
defineOld, defineNew := meta.IsDefined(oldName), meta.IsDefined(newName)
defineOld, _ := meta.IsDefined(oldName), meta.IsDefined(newName)
switch {
case defineOld && defineNew:
if c.TraceRegionFlow && (c.FlowRoundByDigit == defaultFlowRoundByDigit) {
return errors.Errorf("config item %s and %s(deprecated) are conflict", newName, oldName)
}
case defineOld && !defineNew:
if !c.TraceRegionFlow {
c.FlowRoundByDigit = math.MaxInt8
}
case defineOld:
return errors.Errorf("config item %s and %s(deprecated) are conflict", newName, oldName)
default:
}
return nil
}

// MigrateDeprecatedFlags updates new flags according to deprecated flags.
func (c *PDServerConfig) MigrateDeprecatedFlags() {
if !c.TraceRegionFlow {
c.FlowRoundByDigit = math.MaxInt8
}
// json omity the false. next time will not persist to the kv.
c.TraceRegionFlow = false
}

// Clone returns a cloned PD server config.
func (c *PDServerConfig) Clone() *PDServerConfig {
runtimeServices := append(c.RuntimeServices[:0:0], c.RuntimeServices...)
Expand Down
1 change: 0 additions & 1 deletion server/config/persist_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,6 @@ func (o *PersistOptions) Reload(storage endpoint.ConfigStorage) error {
adjustScheduleCfg(&cfg.Schedule)
// Some fields may not be stored in the storage, we need to calculate them manually.
cfg.StoreConfig.Adjust()
cfg.PDServerCfg.MigrateDeprecatedFlags()
if isExist {
o.schedule.Store(&cfg.Schedule)
o.replication.Store(&cfg.Replication)
Expand Down

0 comments on commit b888156

Please sign in to comment.