Skip to content

Commit

Permalink
config: warn undefined config item
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <nolouch@gmail.com>
  • Loading branch information
nolouch committed Jun 11, 2019
1 parent bb0634b commit 80c1234
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion conf/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ leader-schedule-limit = 4
region-schedule-limit = 1024
replica-schedule-limit = 1024
merge-schedule-limit = 8
tolerant-size-ratio = 0
# tolerant-size-ratio = 0.0

# customized schedulers, the format is as below
# if empty, it will use balance-leader, balance-region, hot-region as default
Expand All @@ -83,6 +83,7 @@ max-replicas = 3
# For example, ["zone", "rack"] means that we should place replicas to
# different zones first, then to different racks if we don't have enough zones.
location-labels = []
# strictly-match-label = false

[label-property]
# Do not assign region leaders to stores that have these tags.
Expand Down
2 changes: 1 addition & 1 deletion server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,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())
}

if c.Name == "" {
Expand Down
4 changes: 3 additions & 1 deletion server/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"fmt"
"os"
"path"
"strings"
"time"

"github.com/BurntSushi/toml"
Expand Down Expand Up @@ -131,7 +132,8 @@ 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)

// Check misspelled schedulers name
cfgData = `
Expand Down

0 comments on commit 80c1234

Please sign in to comment.