Skip to content

Commit

Permalink
fix(config): An issue that random ports can't be assgined (#2384)
Browse files Browse the repository at this point in the history
Fixes #2382. The condition of assigning a random port for protocols should be that port
is less than or equal to 0, not the length of the port string.
  • Loading branch information
justxuewei committed Aug 16, 2023
1 parent 570539b commit bf5f2dd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion config/service_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ func (s *ServiceConfig) IsExport() bool {
func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List {
ports := list.New()
for _, proto := range protocolConfigs {
if len(proto.Port) > 0 {
if port, err := strconv.Atoi(proto.Port); err != nil {
logger.Infof(
"%s will be assgined to a random port, since the port is an invalid number",
proto.Name,
)
} else if port > 0 {
continue
}

Expand Down

0 comments on commit bf5f2dd

Please sign in to comment.