Skip to content

Commit

Permalink
Merge pull request #379 from nak3/const-aws
Browse files Browse the repository at this point in the history
Use const value for AWS metadata URL
  • Loading branch information
catsby committed Nov 3, 2015
2 parents 2cdedc6 + 84dc194 commit fd5be4d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/fingerprint/env_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import (
"github.com/hashicorp/nomad/nomad/structs"
)

// This is where the AWS metadata server normally resides. We hardcode the
// "instance" path as well since it's the only one we access here.
const DEFAULT_AWS_URL = "http//169.254.169.254/latest/meta-data/"

// map of instance type to approximate speed, in Mbits/s
// http://serverfault.com/questions/324883/aws-bandwidth-and-content-delivery/326797#326797
// which itself cites these sources:
Expand Down Expand Up @@ -89,7 +93,7 @@ func (f *EnvAWSFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
}
metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" {
metadataURL = "http://169.254.169.254/latest/meta-data/"
metadataURL = DEFAULT_AWS_URL
}

// assume 2 seconds is enough time for inside AWS network
Expand Down Expand Up @@ -161,7 +165,7 @@ func isAWS() bool {
// provide their own
metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" {
metadataURL = "http://169.254.169.254/latest/meta-data/"
metadataURL = DEFAULT_AWS_URL
}

// assume 2 seconds is enough time for inside AWS network
Expand Down Expand Up @@ -205,7 +209,7 @@ func (f *EnvAWSFingerprint) linkSpeed() int {
// the network speed
metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" {
metadataURL = "http://169.254.169.254/latest/meta-data/"
metadataURL = DEFAULT_AWS_URL
}

// assume 2 seconds is enough time for inside AWS network
Expand Down

0 comments on commit fd5be4d

Please sign in to comment.