From 758e98b9a95f1993f022d95879673c8a755c3f37 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 19 Apr 2023 06:46:56 -0400 Subject: [PATCH] cmd/devp2p: make crawler-route53-updater less verbose (#27116) Follow-up to #26697, makes the crawler less verbose on route53-based scenarios. It also changes the loglevel from debug to info on Updates, which are typically the root, and can be interesting to see. --- cmd/devp2p/dns_cloudflare.go | 2 +- cmd/devp2p/dns_route53.go | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cmd/devp2p/dns_cloudflare.go b/cmd/devp2p/dns_cloudflare.go index bfe92257ee5a..798fdc733245 100644 --- a/cmd/devp2p/dns_cloudflare.go +++ b/cmd/devp2p/dns_cloudflare.go @@ -144,7 +144,7 @@ func (c *cloudflareClient) uploadRecords(name string, records map[string]string) _, err = c.CreateDNSRecord(context.Background(), c.zoneID, record) } else if old.Content != val { // Entry already exists, only change its content. - log.Debug(fmt.Sprintf("Updating %s from %q to %q", path, old.Content, val)) + log.Info(fmt.Sprintf("Updating %s from %q to %q", path, old.Content, val)) updated++ old.Content = val err = c.UpdateDNSRecord(context.Background(), c.zoneID, old.ID, old) diff --git a/cmd/devp2p/dns_route53.go b/cmd/devp2p/dns_route53.go index 81734eb2ad87..400ab1b1cf05 100644 --- a/cmd/devp2p/dns_route53.go +++ b/cmd/devp2p/dns_route53.go @@ -221,7 +221,13 @@ func (c *route53Client) computeChanges(name string, records map[string]string, e } records = lrecords - var changes []types.Change + var ( + changes []types.Change + inserts int + upserts int + skips int + ) + for path, newValue := range records { prevRecords, exists := existing[path] prevValue := strings.Join(prevRecords.values, "") @@ -237,20 +243,30 @@ func (c *route53Client) computeChanges(name string, records map[string]string, e if !exists { // Entry is unknown, push a new one - log.Info(fmt.Sprintf("Creating %s = %s", path, newValue)) + log.Debug(fmt.Sprintf("Creating %s = %s", path, newValue)) changes = append(changes, newTXTChange("CREATE", path, ttl, newValue)) + inserts++ } else if prevValue != newValue || prevRecords.ttl != ttl { // Entry already exists, only change its content. log.Info(fmt.Sprintf("Updating %s from %s to %s", path, prevValue, newValue)) changes = append(changes, newTXTChange("UPSERT", path, ttl, newValue)) + upserts++ } else { log.Debug(fmt.Sprintf("Skipping %s = %s", path, newValue)) + skips++ } } // Iterate over the old records and delete anything stale. - changes = append(changes, makeDeletionChanges(existing, records)...) - + deletions := makeDeletionChanges(existing, records) + changes = append(changes, deletions...) + + log.Info("Computed DNS changes", + "changes", len(changes), + "inserts", inserts, + "skips", skips, + "deleted", len(deletions), + "upserts", upserts) // Ensure changes are in the correct order. sortChanges(changes) return changes @@ -263,7 +279,7 @@ func makeDeletionChanges(records map[string]recordSet, keep map[string]string) [ if _, ok := keep[path]; ok { continue } - log.Info(fmt.Sprintf("Deleting %s = %s", path, strings.Join(set.values, ""))) + log.Debug(fmt.Sprintf("Deleting %s = %s", path, strings.Join(set.values, ""))) changes = append(changes, newTXTChange("DELETE", path, set.ttl, set.values...)) } return changes