Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/devp2p: make crawler less verbose (route53) #27116

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/devp2p/dns_cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 21 additions & 5 deletions cmd/devp2p/dns_route53.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand All @@ -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
Expand All @@ -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
Expand Down