diff --git a/pkg/cluster/spec/validate.go b/pkg/cluster/spec/validate.go index 3bdd7bfd15..d08944807c 100644 --- a/pkg/cluster/spec/validate.go +++ b/pkg/cluster/spec/validate.go @@ -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) } } } diff --git a/pkg/cluster/spec/validate_test.go b/pkg/cluster/spec/validate_test.go index f1b8fe1b01..67351e1178 100644 --- a/pkg/cluster/spec/validate_test.go +++ b/pkg/cluster/spec/validate_test.go @@ -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: @@ -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) {