Skip to content

Commit a5c1704

Browse files
committed
Removes logic that checks for a "port already in use" error and instead
retries on any error. The "port already in use" error is only present in the stderr logs of the separate process (etcd or apiserver) and will not be surfaced in the go error. Checking the stderr logs is an alternative solution, but it's fragile (the message could change in the future and varies across operating systems).
1 parent a8ea205 commit a5c1704

File tree

1 file changed

+0
-13
lines changed

1 file changed

+0
-13
lines changed

pkg/envtest/server.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ package envtest
1818

1919
import (
2020
"fmt"
21-
"net"
2221
"os"
2322
"path/filepath"
24-
"strings"
2523
"time"
2624

2725
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
@@ -169,17 +167,6 @@ func (te *Environment) startControlPlane() error {
169167
if err == nil {
170168
break
171169
}
172-
// code snippet copied from following answer on stackoverflow
173-
// https://stackoverflow.com/questions/51151973/catching-bind-address-already-in-use-in-golang
174-
if opErr, ok := err.(*net.OpError); ok {
175-
if opErr.Op == "listen" && strings.Contains(opErr.Error(), "address already in use") {
176-
if stopErr := te.ControlPlane.Stop(); stopErr != nil {
177-
return fmt.Errorf("failed to stop controlplane in response to bind error 'address already in use'")
178-
}
179-
}
180-
} else {
181-
return err
182-
}
183170
}
184171
if numTries == maxRetries {
185172
return fmt.Errorf("failed to start the controlplane. retried %d times", numTries)

0 commit comments

Comments
 (0)