Commit b9882640 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #51085 from frobware/disclose-StartTestServerOrDie-error-message

Automatic merge from submit-queue (batch tested with PRs 50229, 50973, 50976, 51085, 51084) Print root cause failure message in StartTestServerOrDie() **What this PR does / why we need it**: If the test server cannot be started then print the underling root cause as opposed to the generic 'Failed to create server chain'. For example: Failed to create server chain: Model name conflict in merging OpenAPI spec: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIServiceCondition
parents 4d3a752f 0acda5ef
...@@ -128,8 +128,14 @@ func StartTestServerOrDie(t *testing.T) (*restclient.Config, TearDownFunc) { ...@@ -128,8 +128,14 @@ func StartTestServerOrDie(t *testing.T) (*restclient.Config, TearDownFunc) {
// retry test because the bind might fail due to a race with another process // retry test because the bind might fail due to a race with another process
// binding to the port. We cannot listen to :0 (then the kernel would give us // binding to the port. We cannot listen to :0 (then the kernel would give us
// a port which is free for sure), so we need this workaround. // a port which is free for sure), so we need this workaround.
var err error
for retry := 0; retry < 5 && !t.Failed(); retry++ { for retry := 0; retry < 5 && !t.Failed(); retry++ {
config, td, err := StartTestServer(t) var config *restclient.Config
var td TearDownFunc
config, td, err = StartTestServer(t)
if err == nil { if err == nil {
return config, td return config, td
} }
...@@ -139,7 +145,7 @@ func StartTestServerOrDie(t *testing.T) (*restclient.Config, TearDownFunc) { ...@@ -139,7 +145,7 @@ func StartTestServerOrDie(t *testing.T) (*restclient.Config, TearDownFunc) {
t.Logf("Bind error, retrying...") t.Logf("Bind error, retrying...")
} }
t.Fatalf("Failed to launch server") t.Fatalf("Failed to launch server: %v", err)
return nil, nil return nil, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment