From 80c123429b113aa76e61e986309a2f179a92b77f Mon Sep 17 00:00:00 2001 From: nolouch Date: Tue, 11 Jun 2019 18:27:16 +0800 Subject: [PATCH 1/4] config: warn undefined config item Signed-off-by: nolouch --- conf/config.toml | 3 ++- server/config.go | 2 +- server/config_test.go | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/conf/config.toml b/conf/config.toml index a2ccfb9496a..1ed095e252d 100644 --- a/conf/config.toml +++ b/conf/config.toml @@ -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 @@ -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. diff --git a/server/config.go b/server/config.go index 36cda4aebcc..a3bd5341fe4 100644 --- a/server/config.go +++ b/server/config.go @@ -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 == "" { diff --git a/server/config_test.go b/server/config_test.go index 5a5e413a509..86dc933e11e 100644 --- a/server/config_test.go +++ b/server/config_test.go @@ -17,6 +17,7 @@ import ( "fmt" "os" "path" + "strings" "time" "github.com/BurntSushi/toml" @@ -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 = ` From 103814beb7b7f2081e87c4962b101139d8901b2a Mon Sep 17 00:00:00 2001 From: nolouch Date: Wed, 12 Jun 2019 10:36:21 +0800 Subject: [PATCH 2/4] address comments Signed-off-by: nolouch --- conf/config.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conf/config.toml b/conf/config.toml index 1ed095e252d..ff7d69aa977 100644 --- a/conf/config.toml +++ b/conf/config.toml @@ -67,7 +67,7 @@ leader-schedule-limit = 4 region-schedule-limit = 1024 replica-schedule-limit = 1024 merge-schedule-limit = 8 -# tolerant-size-ratio = 0.0 +#tolerant-size-ratio = 5.0 # customized schedulers, the format is as below # if empty, it will use balance-leader, balance-region, hot-region as default @@ -83,7 +83,8 @@ 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 +# Strictly checks if the label of TiKV is matched with LocaltionLabels. +#strictly-match-label = false [label-property] # Do not assign region leaders to stores that have these tags. From 002c50d4306f1aca6715ee241a879f9a5bd540a7 Mon Sep 17 00:00:00 2001 From: nolouch Date: Wed, 12 Jun 2019 14:49:55 +0800 Subject: [PATCH 3/4] address comments Signed-off-by: nolouch --- conf/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.toml b/conf/config.toml index ff7d69aa977..14868634bdd 100644 --- a/conf/config.toml +++ b/conf/config.toml @@ -83,7 +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 checks if the label of TiKV is matched with LocaltionLabels. +# Strictly checks if the label of TiKV is matched with localtion labels. #strictly-match-label = false [label-property] From 68acc3112101c3c055d81021428313c847e28450 Mon Sep 17 00:00:00 2001 From: nolouch Date: Wed, 12 Jun 2019 15:33:44 +0800 Subject: [PATCH 4/4] fix typo Signed-off-by: nolouch --- conf/config.toml | 2 +- server/config.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/config.toml b/conf/config.toml index 14868634bdd..78132f6084a 100644 --- a/conf/config.toml +++ b/conf/config.toml @@ -83,7 +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 checks if the label of TiKV is matched with localtion labels. +# Strictly checks if the label of TiKV is matched with location labels. #strictly-match-label = false [label-property] diff --git a/server/config.go b/server/config.go index a3bd5341fe4..7a1d405b1c1 100644 --- a/server/config.go +++ b/server/config.go @@ -682,7 +682,7 @@ type ReplicationConfig struct { // 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. LocationLabels typeutil.StringSlice `toml:"location-labels,omitempty" json:"location-labels"` - // StrictlyMatchLabel strictly checks if the label of TiKV is matched with LocaltionLabels. + // StrictlyMatchLabel strictly checks if the label of TiKV is matched with LocationLabels. StrictlyMatchLabel bool `toml:"strictly-match-label,omitempty" json:"strictly-match-label,string"` }