Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cluster: make port check error message more clear to users. #1367

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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