From 5036cc277fc8c0e7fa1219265ae407de80b950b7 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Thu, 9 Jan 2025 18:04:46 +0800 Subject: [PATCH] config: completely remove the deprecated field from the PD server config (#8981) (#8985) close tikv/pd#8980 server/config: completely remove the deprecated field from the PD server config Signed-off-by: nolouch Co-authored-by: nolouch --- server/config/config.go | 30 +++++------------------- server/config/config_test.go | 2 +- server/config/persist_options.go | 1 - tools/pd-ctl/tests/config/config_test.go | 1 - 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/server/config/config.go b/server/config/config.go index c64ee3831b0..2f67eac0bde 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -18,7 +18,6 @@ import ( "crypto/tls" "encoding/json" "fmt" - "math" "net/url" "os" "path/filepath" @@ -515,9 +514,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. @@ -581,37 +577,23 @@ func (c *PDServerConfig) adjust(meta *configutil.ConfigMetaData) error { } else if c.GCTunerThreshold > maxGCTunerThreshold { c.GCTunerThreshold = maxGCTunerThreshold } - if err := c.migrateConfigurationFromFile(meta); err != nil { + if err := migrateConfigurationFromFile(meta); err != nil { return err } return c.Validate() } -func (c *PDServerConfig) migrateConfigurationFromFile(meta *configutil.ConfigMetaData) error { +func migrateConfigurationFromFile(meta *configutil.ConfigMetaData) error { oldName, newName := "trace-region-flow", "flow-round-by-digit" - defineOld, defineNew := meta.IsDefined(oldName), meta.IsDefined(newName) + defineOld := meta.IsDefined(oldName) 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...) diff --git a/server/config/config_test.go b/server/config/config_test.go index 78d6d25b73e..b85fc15fa7d 100644 --- a/server/config/config_test.go +++ b/server/config/config_test.go @@ -276,7 +276,7 @@ func TestMigrateFlags(t *testing.T) { } cfg, err := load(` [pd-server] -trace-region-flow = false +flow-round-by-digit = 127 [schedule] disable-remove-down-replica = true enable-make-up-replica = false diff --git a/server/config/persist_options.go b/server/config/persist_options.go index c426e9d2420..ebc3f244067 100644 --- a/server/config/persist_options.go +++ b/server/config/persist_options.go @@ -815,7 +815,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) diff --git a/tools/pd-ctl/tests/config/config_test.go b/tools/pd-ctl/tests/config/config_test.go index 7391f57366e..f5fb6ce84c2 100644 --- a/tools/pd-ctl/tests/config/config_test.go +++ b/tools/pd-ctl/tests/config/config_test.go @@ -148,7 +148,6 @@ func (suite *configTestSuite) checkConfig(cluster *pdTests.TestCluster) { args = []string{"-u", pdAddr, "config", "set", "trace-region-flow", "false"} _, err = tests.ExecuteCommand(cmd, args...) re.NoError(err) - re.False(svr.GetPDServerConfig().TraceRegionFlow) origin := svr.GetPDServerConfig().FlowRoundByDigit args = []string{"-u", pdAddr, "config", "set", "flow-round-by-digit", "10"}