From 3647b5e5603da9f2bfd7de75b9bd9d68f876d88e Mon Sep 17 00:00:00 2001 From: winkyao Date: Tue, 2 Apr 2019 11:15:48 +0800 Subject: [PATCH] address comments --- config/config.go | 7 ++++++- tidb-server/main.go | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 54dbd8824f248..fc1d8d1f7920e 100644 --- a/config/config.go +++ b/config/config.go @@ -23,6 +23,7 @@ import ( "github.com/BurntSushi/toml" "github.com/pingcap/errors" "github.com/pingcap/tidb/util/logutil" + "github.com/prometheus/common/log" tracing "github.com/uber/jaeger-client-go/config" ) @@ -371,7 +372,7 @@ func GetGlobalConfig() *Config { } // Load loads config options from a toml file. -func (c *Config) Load(confFile string) error { +func (c *Config) Load(confFile string, configCheck bool) error { metaData, err := toml.DecodeFile(confFile, c) if c.TokenLimit <= 0 { c.TokenLimit = 1000 @@ -386,6 +387,10 @@ func (c *Config) Load(confFile string) error { undecodedItems += fmt.Sprintf(" %s \n", item.String()) } err = errors.Errorf("config file %s contained unknown configuration options:\n%s", confFile, undecodedItems) + if !configCheck { + log.Warn(err) + err = nil + } } return errors.Trace(err) diff --git a/tidb-server/main.go b/tidb-server/main.go index 3e5125b5b77fe..4343e6a79ec51 100644 --- a/tidb-server/main.go +++ b/tidb-server/main.go @@ -141,7 +141,7 @@ func main() { } registerStores() registerMetrics() - loadConfig() + loadConfig(*configCheck) overrideConfig() validateConfig() if *configCheck { @@ -291,10 +291,10 @@ func flagBoolean(name string, defaultVal bool, usage string) *bool { return flag.Bool(name, defaultVal, usage) } -func loadConfig() { +func loadConfig(configCheck bool) { cfg = config.GetGlobalConfig() if *configPath != "" { - err := cfg.Load(*configPath) + err := cfg.Load(*configPath, configCheck) terror.MustNil(err) } }