Skip to content

Commit

Permalink
Removes logic that checks for a "port already in use" error and instead
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
mjnichol2 committed Oct 31, 2018
1 parent a8ea205 commit a5c1704
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions pkg/envtest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ package envtest

import (
"fmt"
"net"
"os"
"path/filepath"
"strings"
"time"

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

0 comments on commit a5c1704

Please sign in to comment.