Merge pull request #58937 from hzxuzhonghu/pass-listener

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

pass listener in integration test

**What this PR does / why we need it**:

pass listener to `SecureServingOptions` to prevent port in use flake.
partially fix #58936

**Special notes for your reviewer**:

/assign @liggitt @sttts @caesarxuchao 

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue
2018-02-13 06:22:53 -08:00
committed by GitHub
12 changed files with 157 additions and 176 deletions

View File

@@ -21,7 +21,6 @@ import (
"net/http"
"net/http/httptest"
"path"
"strconv"
"time"
"github.com/go-openapi/spec"
@@ -328,28 +327,6 @@ func RunAMasterUsingServer(masterConfig *master.Config, s *httptest.Server, mast
return startMasterOrDie(masterConfig, s, masterReceiver)
}
// FindFreeLocalPort returns the number of an available port number on
// the loopback interface. Useful for determining the port to launch
// a server on. Error handling required - there is a non-zero chance
// that the returned port number will be bound by another process
// after this function returns.
func FindFreeLocalPort() (int, error) {
l, err := net.Listen("tcp", ":0")
if err != nil {
return 0, err
}
defer l.Close()
_, portStr, err := net.SplitHostPort(l.Addr().String())
if err != nil {
return 0, err
}
port, err := strconv.Atoi(portStr)
if err != nil {
return 0, err
}
return port, nil
}
// SharedEtcd creates a storage config for a shared etcd instance, with a unique prefix.
func SharedEtcd() *storagebackend.Config {
cfg := storagebackend.NewDefaultConfig(path.Join(uuid.New(), "registry"), nil)