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

fix(config): Random ports can't be assgined #2384

Merged
merged 1 commit into from
Aug 16, 2023
Merged
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
fix(config): An issue that random ports can't be assgined
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.

Fixes: #2382

Signed-off-by: Xuewei Niu <justxuewei@apache.org>
  • Loading branch information
justxuewei committed Aug 15, 2023
commit 6a81761f32ed310038aad07668b8228067e455c6
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
Loading