Skip to content

Commit 2b0a34b

Browse files
authored
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.
1 parent 3768b00 commit 2b0a34b

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

cmd/devp2p/dns_cloudflare.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (c *cloudflareClient) uploadRecords(name string, records map[string]string)
144144
_, err = c.CreateDNSRecord(context.Background(), c.zoneID, record)
145145
} else if old.Content != val {
146146
// Entry already exists, only change its content.
147-
log.Debug(fmt.Sprintf("Updating %s from %q to %q", path, old.Content, val))
147+
log.Info(fmt.Sprintf("Updating %s from %q to %q", path, old.Content, val))
148148
updated++
149149
old.Content = val
150150
err = c.UpdateDNSRecord(context.Background(), c.zoneID, old.ID, old)

cmd/devp2p/dns_route53.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,13 @@ func (c *route53Client) computeChanges(name string, records map[string]string, e
221221
}
222222
records = lrecords
223223

224-
var changes []types.Change
224+
var (
225+
changes []types.Change
226+
inserts int
227+
upserts int
228+
skips int
229+
)
230+
225231
for path, newValue := range records {
226232
prevRecords, exists := existing[path]
227233
prevValue := strings.Join(prevRecords.values, "")
@@ -237,20 +243,30 @@ func (c *route53Client) computeChanges(name string, records map[string]string, e
237243

238244
if !exists {
239245
// Entry is unknown, push a new one
240-
log.Info(fmt.Sprintf("Creating %s = %s", path, newValue))
246+
log.Debug(fmt.Sprintf("Creating %s = %s", path, newValue))
241247
changes = append(changes, newTXTChange("CREATE", path, ttl, newValue))
248+
inserts++
242249
} else if prevValue != newValue || prevRecords.ttl != ttl {
243250
// Entry already exists, only change its content.
244251
log.Info(fmt.Sprintf("Updating %s from %s to %s", path, prevValue, newValue))
245252
changes = append(changes, newTXTChange("UPSERT", path, ttl, newValue))
253+
upserts++
246254
} else {
247255
log.Debug(fmt.Sprintf("Skipping %s = %s", path, newValue))
256+
skips++
248257
}
249258
}
250259

251260
// Iterate over the old records and delete anything stale.
252-
changes = append(changes, makeDeletionChanges(existing, records)...)
253-
261+
deletions := makeDeletionChanges(existing, records)
262+
changes = append(changes, deletions...)
263+
264+
log.Info("Computed DNS changes",
265+
"changes", len(changes),
266+
"inserts", inserts,
267+
"skips", skips,
268+
"deleted", len(deletions),
269+
"upserts", upserts)
254270
// Ensure changes are in the correct order.
255271
sortChanges(changes)
256272
return changes
@@ -263,7 +279,7 @@ func makeDeletionChanges(records map[string]recordSet, keep map[string]string) [
263279
if _, ok := keep[path]; ok {
264280
continue
265281
}
266-
log.Info(fmt.Sprintf("Deleting %s = %s", path, strings.Join(set.values, "")))
282+
log.Debug(fmt.Sprintf("Deleting %s = %s", path, strings.Join(set.values, "")))
267283
changes = append(changes, newTXTChange("DELETE", path, set.ttl, set.values...))
268284
}
269285
return changes

0 commit comments

Comments
 (0)