Merge pull request #379 from nak3/const-aws

Use const value for AWS metadata URL
This commit is contained in:
Clint 2015-11-03 10:09:30 -06:00
commit 6a3763d105

View file

@ -15,6 +15,10 @@ import (
"github.com/hashicorp/nomad/nomad/structs" "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 // map of instance type to approximate speed, in Mbits/s
// http://serverfault.com/questions/324883/aws-bandwidth-and-content-delivery/326797#326797 // http://serverfault.com/questions/324883/aws-bandwidth-and-content-delivery/326797#326797
// which itself cites these sources: // which itself cites these sources:
@ -89,7 +93,7 @@ func (f *EnvAWSFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
} }
metadataURL := os.Getenv("AWS_ENV_URL") metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" { 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 // assume 2 seconds is enough time for inside AWS network
@ -161,7 +165,7 @@ func isAWS() bool {
// provide their own // provide their own
metadataURL := os.Getenv("AWS_ENV_URL") metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" { 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 // assume 2 seconds is enough time for inside AWS network
@ -205,7 +209,7 @@ func (f *EnvAWSFingerprint) linkSpeed() int {
// the network speed // the network speed
metadataURL := os.Getenv("AWS_ENV_URL") metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" { 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 // assume 2 seconds is enough time for inside AWS network