Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: completely remove the deprecated field from the PD server config #8981

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 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 @@ -573,37 +569,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), meta.IsDefined(newName)
nolouch marked this conversation as resolved.
Show resolved Hide resolved
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to report an error? How about print a warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to report the error, as the previous behavior also did.

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
Loading