Skip to content

Commit

Permalink
cluster: make port check error message more clear to users. (#1367)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ling Jin authored May 18, 2021
1 parent f7ca6e5 commit 3202e61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/cluster/spec/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func (s *Specification) portInvalidDetect() error {
port := int(compSpec.Field(i).Int())
if port <= 0 || port >= 65535 {
portField := strings.Split(compSpec.Type().Field(i).Tag.Get("yaml"), ",")[0]
return errors.Errorf("`%s` of %s=%d is invalid", cfg, portField, port)
return errors.Errorf("`%s` of %s=%d is invalid, port should be in the range [0, 65535]", cfg, portField, port)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/spec/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ global:
ssh_port: 65536
`), &topo)
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "`global` of ssh_port=65536 is invalid")
c.Assert(err.Error(), Equals, "`global` of ssh_port=65536 is invalid, port should be in the range [0, 65535]")

err = yaml.Unmarshal([]byte(`
global:
Expand All @@ -939,14 +939,14 @@ tidb_servers:
port: -1
`), &topo)
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "`tidb_servers` of port=-1 is invalid")
c.Assert(err.Error(), Equals, "`tidb_servers` of port=-1 is invalid, port should be in the range [0, 65535]")

err = yaml.Unmarshal([]byte(`
monitored:
node_exporter_port: 102400
`), &topo)
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "`monitored` of node_exporter_port=102400 is invalid")
c.Assert(err.Error(), Equals, "`monitored` of node_exporter_port=102400 is invalid, port should be in the range [0, 65535]")
}

func (s *metaSuiteTopo) TestInvalidUserGroup(c *C) {
Expand Down

0 comments on commit 3202e61

Please sign in to comment.