Merge pull request #20493 from edsantiago/getport_safe

CI: e2e: safer GetPort()
This commit is contained in:
openshift-ci[bot] 2023-10-26 13:37:13 +00:00 committed by GitHub
commit c1d177e8e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1233,7 +1233,7 @@ func GetPort() int {
// Random port within that range
port := portMin + rng.Intn((portMax-portMin)/nProcs)*nProcs + myProc
used, err := net.Listen("tcp", "localhost:"+strconv.Itoa(port))
used, err := net.Listen("tcp", "0.0.0.0:"+strconv.Itoa(port))
if err == nil {
// it's open. Return it.
err = used.Close()
@ -1242,7 +1242,7 @@ func GetPort() int {
}
}
Fail(fmt.Sprintf("unable to get free port: %v", err))
Fail(fmt.Sprintf("unable to get free port in range %d-%d", portMin, portMax))
return 0 // notreached
}