Skip to content

Commit bf361c8

Browse files
ti-chi-botnolouchokJiang
authored
config: completely remove the deprecated field from the PD server config (#8981) (#9026)
close #8980 server/config: completely remove the deprecated field from the PD server config Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io> Signed-off-by: nolouch <nolouch@gmail.com> Co-authored-by: ShuNing <nolouch@gmail.com> Co-authored-by: nolouch <nolouch@gmail.com> Co-authored-by: okJiang <819421878@qq.com>
1 parent 8325c12 commit bf361c8

File tree

4 files changed

+8
-32
lines changed

4 files changed

+8
-32
lines changed

server/config/config.go

+6-24
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"encoding/json"
2020
"flag"
2121
"fmt"
22-
"math"
2322
"net/url"
2423
"os"
2524
"path/filepath"
@@ -1159,9 +1158,6 @@ type PDServerConfig struct {
11591158
MetricStorage string `toml:"metric-storage" json:"metric-storage"`
11601159
// There are some values supported: "auto", "none", or a specific address, default: "auto"
11611160
DashboardAddress string `toml:"dashboard-address" json:"dashboard-address"`
1162-
// TraceRegionFlow the option to update flow information of regions.
1163-
// WARN: TraceRegionFlow is deprecated.
1164-
TraceRegionFlow bool `toml:"trace-region-flow" json:"trace-region-flow,string,omitempty"`
11651161
// FlowRoundByDigit used to discretization processing flow information.
11661162
FlowRoundByDigit int `toml:"flow-round-by-digit" json:"flow-round-by-digit"`
11671163
// MinResolvedTSPersistenceInterval is the interval to save the min resolved ts.
@@ -1188,35 +1184,21 @@ func (c *PDServerConfig) adjust(meta *configMetaData) error {
11881184
if !meta.IsDefined("min-resolved-ts-persistence-interval") {
11891185
adjustDuration(&c.MinResolvedTSPersistenceInterval, DefaultMinResolvedTSPersistenceInterval)
11901186
}
1191-
c.migrateConfigurationFromFile(meta)
1187+
migrateConfigurationFromFile(meta)
11921188
return c.Validate()
11931189
}
11941190

1195-
func (c *PDServerConfig) migrateConfigurationFromFile(meta *configMetaData) error {
1191+
func migrateConfigurationFromFile(meta *configMetaData) error {
11961192
oldName, newName := "trace-region-flow", "flow-round-by-digit"
1197-
defineOld, defineNew := meta.IsDefined(oldName), meta.IsDefined(newName)
1193+
defineOld := meta.IsDefined(oldName)
11981194
switch {
1199-
case defineOld && defineNew:
1200-
if c.TraceRegionFlow && (c.FlowRoundByDigit == defaultFlowRoundByDigit) {
1201-
return errors.Errorf("config item %s and %s(deprecated) are conflict", newName, oldName)
1202-
}
1203-
case defineOld && !defineNew:
1204-
if !c.TraceRegionFlow {
1205-
c.FlowRoundByDigit = math.MaxInt8
1206-
}
1195+
case defineOld:
1196+
return errors.Errorf("config item %s and %s(deprecated) are conflict", newName, oldName)
1197+
default:
12071198
}
12081199
return nil
12091200
}
12101201

1211-
// MigrateDeprecatedFlags updates new flags according to deprecated flags.
1212-
func (c *PDServerConfig) MigrateDeprecatedFlags() {
1213-
if !c.TraceRegionFlow {
1214-
c.FlowRoundByDigit = math.MaxInt8
1215-
}
1216-
// json omity the false. next time will not persist to the kv.
1217-
c.TraceRegionFlow = false
1218-
}
1219-
12201202
// Clone returns a cloned PD server config.
12211203
func (c *PDServerConfig) Clone() *PDServerConfig {
12221204
runtimeServices := append(c.RuntimeServices[:0:0], c.RuntimeServices...)

server/config/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func TestMigrateFlags(t *testing.T) {
295295
}
296296
cfg, err := load(`
297297
[pd-server]
298-
trace-region-flow = false
298+
flow-round-by-digit = 127
299299
[schedule]
300300
disable-remove-down-replica = true
301301
enable-make-up-replica = false

server/config/persist_options.go

-1
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,6 @@ func (o *PersistOptions) Reload(storage endpoint.ConfigStorage) error {
704704
return err
705705
}
706706
o.adjustScheduleCfg(&cfg.Schedule)
707-
cfg.PDServerCfg.MigrateDeprecatedFlags()
708707
if isExist {
709708
o.schedule.Store(&cfg.Schedule)
710709
o.replication.Store(&cfg.Replication)

tests/pdctl/config/config_test.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,7 @@ func TestConfig(t *testing.T) {
9494
re.Equal(scheduleConfig, &cfg.Schedule)
9595
re.Equal(svr.GetReplicationConfig(), &cfg.Replication)
9696

97-
// config set trace-region-flow <value>
98-
args = []string{"-u", pdAddr, "config", "set", "trace-region-flow", "false"}
99-
_, err = pdctl.ExecuteCommand(cmd, args...)
100-
re.NoError(err)
101-
re.False(svr.GetPDServerConfig().TraceRegionFlow)
102-
97+
// config set flow-round-by-digit
10398
args = []string{"-u", pdAddr, "config", "set", "flow-round-by-digit", "10"}
10499
_, err = pdctl.ExecuteCommand(cmd, args...)
105100
re.NoError(err)

0 commit comments

Comments
 (0)