Merge pull request #319 from hashicorp/cleanhttp

Use cleanhttp for truly clean clients and transports.
This commit is contained in:
Alex Dadgar
2015-10-22 09:52:54 -07:00
4 changed files with 16 additions and 6 deletions

View File

@@ -10,6 +10,8 @@ import (
"os"
"strconv"
"time"
"github.com/hashicorp/cleanhttp"
)
// QueryOptions are used to parameterize a query
@@ -86,7 +88,7 @@ type Config struct {
func DefaultConfig() *Config {
config := &Config{
Address: "http://127.0.0.1:4646",
HttpClient: &http.Client{},
HttpClient: cleanhttp.DefaultClient(),
}
if addr := os.Getenv("NOMAD_ADDR"); addr != "" {
config.Address = addr

View File

@@ -10,6 +10,7 @@ import (
"strings"
"time"
"github.com/hashicorp/cleanhttp"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/nomad/structs"
)
@@ -93,7 +94,8 @@ func (f *EnvAWSFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
// assume 2 seconds is enough time for inside AWS network
client := &http.Client{
Timeout: 2 * time.Second,
Timeout: 2 * time.Second,
Transport: cleanhttp.DefaultTransport(),
}
keys := []string{
@@ -164,7 +166,8 @@ func isAWS() bool {
// assume 2 seconds is enough time for inside AWS network
client := &http.Client{
Timeout: 2 * time.Second,
Timeout: 2 * time.Second,
Transport: cleanhttp.DefaultTransport(),
}
// Query the metadata url for the ami-id, to veryify we're on AWS
@@ -207,7 +210,8 @@ func (f *EnvAWSFingerprint) linkSpeed() int {
// assume 2 seconds is enough time for inside AWS network
client := &http.Client{
Timeout: 2 * time.Second,
Timeout: 2 * time.Second,
Transport: cleanhttp.DefaultTransport(),
}
res, err := client.Get(metadataURL + "instance-type")

View File

@@ -12,6 +12,7 @@ import (
"strings"
"time"
"github.com/hashicorp/cleanhttp"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/nomad/structs"
)
@@ -61,7 +62,8 @@ func NewEnvGCEFingerprint(logger *log.Logger) Fingerprint {
// assume 2 seconds is enough time for inside GCE network
client := &http.Client{
Timeout: 2 * time.Second,
Timeout: 2 * time.Second,
Transport: cleanhttp.DefaultTransport(),
}
return &EnvGCEFingerprint{

View File

@@ -22,6 +22,8 @@ import (
"os/exec"
"sync/atomic"
"testing"
"github.com/hashicorp/cleanhttp"
)
// offset is used to atomically increment the port numbers.
@@ -156,7 +158,7 @@ func NewTestServer(t *testing.T, cb ServerConfigCallback) *TestServer {
t.Fatalf("err: %s", err)
}
client := &http.Client{}
client := cleanhttp.DefaultClient()
server := &TestServer{
Config: nomadConfig,