From dbc72eaac0c3d9893c4e042d881977974f480b8d Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Wed, 11 Jan 2017 22:37:22 -0500 Subject: [PATCH] Condense gce discovery logging a bit --- command/agent/command.go | 7 +++---- website/source/docs/agent/options.html.markdown | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/command/agent/command.go b/command/agent/command.go index dd616a742b..0e81d35e44 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -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) } } diff --git a/website/source/docs/agent/options.html.markdown b/website/source/docs/agent/options.html.markdown index 2fa1152399..a3eef7668b 100644 --- a/website/source/docs/agent/options.html.markdown +++ b/website/source/docs/agent/options.html.markdown @@ -216,7 +216,7 @@ will exit with an error at startup. - 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. * `-retry-join-gce-project-name` - The project to search in for the tag supplied by