vendor: upgrade github.com/hashicorp/go-discover

Pull in improved debug logging for AWS
pull/3416/head
Frank Schroeder 7 years ago committed by Frank Schröder
parent 0516deff0c
commit ad82659eed

@ -17,10 +17,10 @@ The following cloud providers have implementations in the go-discover/provider
sub packages. Additional providers can be added through the [Register](https://godoc.org/github.com/hashicorp/go-discover#Register) sub packages. Additional providers can be added through the [Register](https://godoc.org/github.com/hashicorp/go-discover#Register)
function. function.
* Amazon AWS [Config options](http://godoc.org/github.com/hashicorp/go-discover/aws) * Amazon AWS [Config options](http://godoc.org/github.com/hashicorp/go-discover/provider/aws)
* Google Cloud [Config options](http://godoc.org/github.com/hashicorp/go-discover/gce) * Google Cloud [Config options](http://godoc.org/github.com/hashicorp/go-discover/provider/gce)
* Microsoft Azure [Config options](http://godoc.org/github.com/hashicorp/go-discover/azure) * Microsoft Azure [Config options](http://godoc.org/github.com/hashicorp/go-discover/provider/azure)
* SoftLayer [Config options](http://godoc.org/github.com/hashicorp/go-discover/softlayer) * SoftLayer [Config options](http://godoc.org/github.com/hashicorp/go-discover/provider/softlayer)
### Config Example ### Config Example

@ -110,5 +110,7 @@ func (d *Discover) Addrs(cfg string, l *log.Logger) ([]string, error) {
if p == nil { if p == nil {
return nil, fmt.Errorf("discover: unknown provider " + name) return nil, fmt.Errorf("discover: unknown provider " + name)
} }
l.Printf("[DEBUG] discover: Using provider %q", name)
return p.Addrs(args, l) return p.Addrs(args, l)
} }

@ -46,17 +46,26 @@ func (p *Provider) Addrs(args map[string]string, l *log.Logger) ([]string, error
accessKey := args["access_key_id"] accessKey := args["access_key_id"]
secretKey := args["secret_access_key"] secretKey := args["secret_access_key"]
log.Printf("[DEBUG] discover-aws: Using region=%s tag_key=%s tag_value=%s", region, tagKey, tagValue)
if accessKey == "" && secretKey == "" {
log.Printf("[DEBUG] discover-aws: No static credentials")
log.Printf("[DEBUG] discover-aws: Using environment variables, shared credentials or instance role")
} else {
log.Printf("[DEBUG] discover-aws: Static credentials provided")
}
if region == "" { if region == "" {
l.Printf("[INFO] discover-aws: Looking up region") l.Printf("[INFO] discover-aws: Region not provided. Looking up region in metadata...")
ec2meta := ec2metadata.New(session.New()) ec2meta := ec2metadata.New(session.New())
identity, err := ec2meta.GetInstanceIdentityDocument() identity, err := ec2meta.GetInstanceIdentityDocument()
if err != nil { if err != nil {
return nil, fmt.Errorf("discover-aws: %s", err) return nil, fmt.Errorf("discover-aws: GetInstanceIdentityDocument failed: %s", err)
} }
region = identity.Region region = identity.Region
} }
l.Printf("[INFO] discover-aws: Region is %s", region) l.Printf("[INFO] discover-aws: Region is %s", region)
l.Printf("[DEBUG] discover-aws: Creating session...")
svc := ec2.New(session.New(), &aws.Config{ svc := ec2.New(session.New(), &aws.Config{
Region: &region, Region: &region,
Credentials: credentials.NewChainCredentials( Credentials: credentials.NewChainCredentials(
@ -73,29 +82,38 @@ func (p *Provider) Addrs(args map[string]string, l *log.Logger) ([]string, error
}), }),
}) })
l.Printf("[INFO] discover-aws: Filter instances with %s=%s", tagKey, tagValue)
resp, err := svc.DescribeInstances(&ec2.DescribeInstancesInput{ resp, err := svc.DescribeInstances(&ec2.DescribeInstancesInput{
Filters: []*ec2.Filter{ Filters: []*ec2.Filter{
{ &ec2.Filter{
Name: aws.String("tag:" + tagKey), Name: aws.String("tag:" + tagKey),
Values: []*string{aws.String(tagValue)}, Values: []*string{aws.String(tagValue)},
}, },
}, },
}) })
if err != nil { if err != nil {
return nil, fmt.Errorf("discover-aws: %s", err) return nil, fmt.Errorf("discover-aws: DescribeInstancesInput failed: %s", err)
} }
l.Printf("[INFO] discover-aws: Filter instances by %s=%s", tagKey, tagValue)
l.Printf("[DEBUG] discover-aws: Found %d reservations", len(resp.Reservations))
var addrs []string var addrs []string
for i := range resp.Reservations { for _, r := range resp.Reservations {
for _, inst := range resp.Reservations[i].Instances { l.Printf("[DEBUG] discover-aws: Reservation %s has %d instances", *r.ReservationId, len(r.Instances))
for _, inst := range r.Instances {
id := *inst.InstanceId
l.Printf("[DEBUG] discover-aws: Found instance %s", id)
// Terminated instances don't have the PrivateIpAddress field // Terminated instances don't have the PrivateIpAddress field
if inst.PrivateIpAddress == nil { if inst.PrivateIpAddress == nil {
l.Printf("[DEBUG] discover-aws: Instance %s has no private ip", id)
continue continue
} }
l.Printf("[INFO] discover-aws: Found %x", *inst.PrivateIpAddress)
l.Printf("[INFO] discover-aws: Instance %s has private ip %s", id, *inst.PrivateIpAddress)
addrs = append(addrs, *inst.PrivateIpAddress) addrs = append(addrs, *inst.PrivateIpAddress)
} }
} }
l.Printf("[DEBUG] discover-aws: Found ip addresses: %v", addrs)
return addrs, nil return addrs, nil
} }

@ -25,8 +25,8 @@
{"checksumSHA1":"cdOCt0Yb+hdErz8NAQqayxPmRsY=","path":"github.com/hashicorp/errwrap","revision":"7554cd9344cec97297fa6649b055a8c98c2a1e55","revisionTime":"2014-10-28T05:47:10Z"}, {"checksumSHA1":"cdOCt0Yb+hdErz8NAQqayxPmRsY=","path":"github.com/hashicorp/errwrap","revision":"7554cd9344cec97297fa6649b055a8c98c2a1e55","revisionTime":"2014-10-28T05:47:10Z"},
{"checksumSHA1":"nd3S1qkFv7zZxA9be0bw4nT0pe0=","path":"github.com/hashicorp/go-checkpoint","revision":"e4b2dc34c0f698ee04750bf2035d8b9384233e1b","revisionTime":"2015-10-22T18:15:14Z"}, {"checksumSHA1":"nd3S1qkFv7zZxA9be0bw4nT0pe0=","path":"github.com/hashicorp/go-checkpoint","revision":"e4b2dc34c0f698ee04750bf2035d8b9384233e1b","revisionTime":"2015-10-22T18:15:14Z"},
{"checksumSHA1":"b8F628srIitj5p7Y130xc9k0QWs=","path":"github.com/hashicorp/go-cleanhttp","revision":"3573b8b52aa7b37b9358d966a898feb387f62437","revisionTime":"2017-02-11T01:34:15Z"}, {"checksumSHA1":"b8F628srIitj5p7Y130xc9k0QWs=","path":"github.com/hashicorp/go-cleanhttp","revision":"3573b8b52aa7b37b9358d966a898feb387f62437","revisionTime":"2017-02-11T01:34:15Z"},
{"checksumSHA1":"0g3hRu2ynuFBKhurobMnLqMnH3s=","path":"github.com/hashicorp/go-discover","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z"}, {"checksumSHA1":"uNoQWG5h2hzWHjaLi376ZXVaCr4=","path":"github.com/hashicorp/go-discover","revision":"21b26b722865b64ae5809a532d2c18f3a3800129","revisionTime":"2017-08-16T16:53:52Z"},
{"checksumSHA1":"ktNW667wT7z7/l+Lk2g3a/0vCyU=","path":"github.com/hashicorp/go-discover/provider/aws","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true}, {"checksumSHA1":"6wdwVsYyTqW4ReHsWs4mEwoz1FI=","path":"github.com/hashicorp/go-discover/provider/aws","revision":"21b26b722865b64ae5809a532d2c18f3a3800129","revisionTime":"2017-08-16T16:53:52Z","tree":true},
{"checksumSHA1":"r97P32e+VmNMh2vwLkZa1zPEDQU=","path":"github.com/hashicorp/go-discover/provider/azure","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true}, {"checksumSHA1":"r97P32e+VmNMh2vwLkZa1zPEDQU=","path":"github.com/hashicorp/go-discover/provider/azure","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true},
{"checksumSHA1":"KC/MepQsQF17904UShiM61jmaEs=","path":"github.com/hashicorp/go-discover/provider/gce","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true}, {"checksumSHA1":"KC/MepQsQF17904UShiM61jmaEs=","path":"github.com/hashicorp/go-discover/provider/gce","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true},
{"checksumSHA1":"SIyZ44AHIUTBfI336ACpCeybsLg=","path":"github.com/hashicorp/go-discover/provider/softlayer","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true}, {"checksumSHA1":"SIyZ44AHIUTBfI336ACpCeybsLg=","path":"github.com/hashicorp/go-discover/provider/softlayer","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true},

Loading…
Cancel
Save