mirror of
https://github.com/kemko/nomad.git
synced 2026-01-09 20:05:42 +03:00
Handle non 200 codes while getting env metadata
This commit is contained in:
@@ -116,6 +116,10 @@ func (f *EnvAWSFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
|
||||
}
|
||||
for _, k := range keys {
|
||||
res, err := client.Get(metadataURL + k)
|
||||
if res.StatusCode != http.StatusOK {
|
||||
f.logger.Printf("[WARN]: fingerprint.env_aws: Could not read value for attribute %q", k)
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
// if it's a URL error, assume we're not in an AWS environment
|
||||
// TODO: better way to detect AWS? Check xen virtualization?
|
||||
|
||||
@@ -94,7 +94,8 @@ func (f *EnvGCEFingerprint) Get(attribute string, recursive bool) (string, error
|
||||
}
|
||||
|
||||
res, err := f.client.Do(req)
|
||||
if err != nil {
|
||||
if err != nil || res.StatusCode != http.StatusOK {
|
||||
f.logger.Printf("[WARN]: fingerprint.env_gce: Could not read value for attribute %q", attribute)
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user