mirror of https://github.com/status-im/consul.git
Condense gce discovery logging a bit
This commit is contained in:
parent
4831b6de40
commit
dbc72eaac0
|
@ -542,11 +542,12 @@ func (c *Config) discoverGCEHosts(logger *log.Logger) ([]string, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(addresses) > 0 {
|
||||
logger.Printf("[INFO] agent: Discovered %d instances in %s/%s: %v", len(addresses), config.ProjectName, zone, addresses)
|
||||
}
|
||||
servers = append(servers, addresses...)
|
||||
}
|
||||
|
||||
logger.Printf("[INFO] agent: Discovered hosts: %s", strings.Join(servers, ", "))
|
||||
|
||||
return servers, nil
|
||||
}
|
||||
|
||||
|
@ -613,13 +614,11 @@ func gceDiscoverZones(logger *log.Logger, ctx context.Context, computeService *c
|
|||
// returned, but ID is also logged.
|
||||
func gceInstancesAddressesForZone(logger *log.Logger, ctx context.Context, computeService *compute.Service, project, zone, tag string) ([]string, error) {
|
||||
addresses := []string{}
|
||||
logger.Printf("[INFO] agent: Discovering instances in %s/%s matching tag: %s", project, zone, tag)
|
||||
call := computeService.Instances.List(project, zone)
|
||||
if err := call.Pages(ctx, func(page *compute.InstanceList) error {
|
||||
for _, v := range page.Items {
|
||||
for _, t := range v.Tags.Items {
|
||||
if t == tag && len(v.NetworkInterfaces) > 0 && v.NetworkInterfaces[0].NetworkIP != "" {
|
||||
logger.Printf("[INFO] agent: Discovered instance: %s -> %s", v.Name, v.NetworkInterfaces[0].NetworkIP)
|
||||
addresses = append(addresses, v.NetworkInterfaces[0].NetworkIP)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ will exit with an error at startup.
|
|||
</a> - A Google Compute Engine instance tag to filter on. Much like the
|
||||
`-retry-join-ec2-*` options, this gives Consul the option of doing server
|
||||
discovery on [Google Compute Engine](https://cloud.google.com/compute/) by
|
||||
searching the tags assigned to any inparticular instance.
|
||||
searching the tags assigned to any particular instance.
|
||||
|
||||
* <a name="_retry_join_gce_project_name"></a><a href="#_retry_join_gce_project_name">`-retry-join-gce-project-name`
|
||||
</a> - The project to search in for the tag supplied by
|
||||
|
|
Loading…
Reference in New Issue