Skip to content

Commit

Permalink
Merge branch 'master' into api-gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
rleungx authored Jan 19, 2020
2 parents e76bd48 + 29af7b2 commit 3cf6d0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"io/ioutil"
"net/http"
"reflect"
"strings"

"github.com/BurntSushi/toml"
"github.com/pingcap/errcode"
Expand Down Expand Up @@ -147,7 +148,11 @@ func (h *confHandler) mergeConfig(v interface{}, data []byte) (updated bool, fou
}
t := reflect.TypeOf(v).Elem()
for i := 0; i < t.NumField(); i++ {
if _, ok := m[t.Field(i).Tag.Get("json")]; ok {
jsonTag := t.Field(i).Tag.Get("json")
if i := strings.Index(jsonTag, ","); i != -1 { // trim 'foobar,string' to 'foobar'
jsonTag = jsonTag[:i]
}
if _, ok := m[jsonTag]; ok {
return false, true, nil
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/pdctl/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,12 @@ func (s *configTestSuite) TestConfig(c *C) {
_, output, err = pdctl.ExecuteCommandC(cmd, args1...)
c.Assert(err, IsNil)
c.Assert(strings.Contains(string(output), "already been deprecated"), IsTrue)

// set enable-placement-rules twice, make sure it does not return error.
args1 = []string{"-u", pdAddr, "config", "set", "enable-placement-rules", "true"}
_, _, err = pdctl.ExecuteCommandC(cmd, args1...)
c.Assert(err, IsNil)
args1 = []string{"-u", pdAddr, "config", "set", "enable-placement-rules", "true"}
_, _, err = pdctl.ExecuteCommandC(cmd, args1...)
c.Assert(err, IsNil)
}

0 comments on commit 3cf6d0d

Please sign in to comment.