Use retryable http to avoid connection flakes
parent
68b5ed9916
commit
657469310c
|
@ -23,9 +23,9 @@ import (
|
|||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/notify"
|
||||
"k8s.io/minikube/pkg/util"
|
||||
|
@ -33,7 +33,7 @@ import (
|
|||
|
||||
func getSHAFromURL(url string) (string, error) {
|
||||
fmt.Println("Downloading: ", url)
|
||||
r, err := http.Get(url)
|
||||
r, err := retryablehttp.Get(url)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import (
|
|||
|
||||
units "github.com/docker/go-units"
|
||||
"github.com/golang/glog"
|
||||
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -130,7 +131,7 @@ func RetryAfter(attempts int, callback func() error, d time.Duration) (err error
|
|||
|
||||
// ParseSHAFromURL downloads and reads a SHA checksum from an URL
|
||||
func ParseSHAFromURL(url string) (string, error) {
|
||||
r, err := http.Get(url)
|
||||
r, err := retryablehttp.Get(url)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "Error downloading checksum.")
|
||||
} else if r.StatusCode != http.StatusOK {
|
||||
|
|
|
@ -32,6 +32,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/machine/libmachine/state"
|
||||
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
pkgutil "k8s.io/minikube/pkg/util"
|
||||
"k8s.io/minikube/test/integration/util"
|
||||
|
@ -105,7 +106,7 @@ func testDashboard(t *testing.T) {
|
|||
t.Errorf("got host %s, expected 127.0.0.1", host)
|
||||
}
|
||||
|
||||
resp, err := http.Get(u.String())
|
||||
resp, err := retryablehttp.Get(u.String())
|
||||
if err != nil {
|
||||
t.Fatalf("failed get: %v", err)
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
"net/url"
|
||||
|
||||
"github.com/elazarl/goproxy"
|
||||
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
||||
"github.com/phayes/freeport"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -148,7 +149,8 @@ func testProxyDashboard(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("failed to parse %q: %v", s, err)
|
||||
}
|
||||
resp, err := http.Get(u.String())
|
||||
|
||||
resp, err := retryablehttp.Get(u.String())
|
||||
if err != nil {
|
||||
t.Fatalf("failed get: %v", err)
|
||||
}
|
||||
|
|
|
@ -36,24 +36,20 @@ func downloadMinikubeBinary(version string) (*os.File, error) {
|
|||
url := pkgutil.GetBinaryDownloadURL(version, runtime.GOOS)
|
||||
resp, err := retryablehttp.Get(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// t.Fatal(errors.Wrap(err, "Failed to get latest release binary"))
|
||||
return nil, errors.Wrap(err, "Failed to get latest release binary")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
tf, err := ioutil.TempFile("", "minikube")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// t.Fatal(errors.Wrap(err, "Failed to create binary file"))
|
||||
return nil, errors.Wrap(err, "Failed to create binary file")
|
||||
}
|
||||
_, err = io.Copy(tf, resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// t.Fatal(errors.Wrap(err, "Failed to populate temp file"))
|
||||
return nil, errors.Wrap(err, "Failed to populate temp file")
|
||||
}
|
||||
if err := tf.Close(); err != nil {
|
||||
return nil, err
|
||||
// t.Fatal(errors.Wrap(err, "Failed to close temp file"))
|
||||
return nil, errors.Wrap(err, "Failed to close temp file")
|
||||
}
|
||||
|
||||
if runtime.GOOS != "windows" {
|
||||
|
|
Loading…
Reference in New Issue