From e922c3eff272c57af2f5621401dbf97940e01ecf Mon Sep 17 00:00:00 2001 From: ShuNing Date: Thu, 13 Jun 2019 13:37:22 +0800 Subject: [PATCH] config: warn undefined config item (#1577) * config: warn undefined config item Signed-off-by: nolouch --- server/config.go | 2 +- server/config_test.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/config.go b/server/config.go index ed770f3330d..a295e7f92fb 100644 --- a/server/config.go +++ b/server/config.go @@ -332,7 +332,7 @@ func (m *configMetaData) CheckUndecoded() error { func (c *Config) Adjust(meta *toml.MetaData) error { configMetaData := newConfigMetadata(meta) if err := configMetaData.CheckUndecoded(); err != nil { - return err + c.WarningMsgs = append(c.WarningMsgs, err.Error()) } adjustString(&c.Name, defaultName) adjustString(&c.DataDir, fmt.Sprintf("default.%s", c.Name)) diff --git a/server/config_test.go b/server/config_test.go index c7a8d0b625f..c6c92e2059b 100644 --- a/server/config_test.go +++ b/server/config_test.go @@ -15,9 +15,9 @@ package server import ( "path" + "strings" "github.com/BurntSushi/toml" - . "github.com/pingcap/check" "github.com/pingcap/pd/server/core" ) @@ -122,5 +122,6 @@ type = "random-merge" meta, err = toml.Decode(cfgData, &cfg) c.Assert(err, IsNil) err = cfg.Adjust(&meta) - c.Assert(err, NotNil) + c.Assert(err, IsNil) + c.Assert(strings.Contains(cfg.WarningMsgs[0], "Config contains undefined item"), IsTrue) }