carlos / platform Public

steering: summarize duplicate region target drops per pass

Group duplicate-target errors by region, kept box and dropped box. Include
the unique name count and three sorted examples so a legitimate overlap
does not emit one error per host. Cover 135 names in two regions across
two converge passes.
Co-Authored-By: GPT-6 Astra <noreply@openai.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev c9ef61cc7a4162fa0bc354dda358aa1d5ec8d34a parent afff579
2 files changed, +54 −3
  • internal/steering/g3_test.go +37 −2
  • internal/steering/route53.go +17 −1
diff --git a/internal/steering/g3_test.go b/internal/steering/g3_test.go
index 939808128..cfbf69658 100644
--- a/internal/steering/g3_test.go
+++ b/internal/steering/g3_test.go
@@ -85,7 +85,7 @@ func TestG3RegionWinner(t *testing.T) {
t.Fatalf("winner=%s record=%v", winner, rr)
}
}
- if strings.Count(log.String(), "ERROR steering: dropped duplicate region target") != 2 {
+ if strings.Count(log.String(), "ERROR steering: dropped duplicate region target") != 1 || !strings.Contains(log.String(), "name_count=2") {
t.Fatalf("log=%s", log)
}
})
@@ -155,7 +155,7 @@ func TestG3RegionWinnerPreservesReplicaHome(t *testing.T) {
if !foundHome {
t.Fatal("home record was deleted")
}
- if strings.Count(log.String(), "dropped duplicate region target") != 1 || !strings.Contains(log.String(), "name=edge.example.com.") {
+ if strings.Count(log.String(), "dropped duplicate region target") != 1 || !strings.Contains(log.String(), "examples=[edge.example.com.]") {
t.Fatalf("log=%s", log)
}
writes := f.writes()
@@ -317,3 +317,38 @@ func TestG3UncertainWriteAndCleanupReadFailure(t *testing.T) {
})
}
}
+
+func TestG3RegionDropLogSummary(t *testing.T) {
+ f := newFake()
+ var routes []registry.Route
+ for i := range 134 {
+ routes = append(routes, steeredRoute(fmt.Sprintf("h%03d.example.com", i)))
+ }
+ var bodies [][]byte
+ for _, region := range []string{"us-east-1", "eu-west-1"} {
+ for i, box := range []string{"a", "b", "c"} {
+ bodies = append(bodies, []byte(fmt.Sprintf(`{"v":1,"box":%q,"eip":"192.0.2.%d","region":%q,"serves_shared_pool":true}`, box+"-"+region, i+1, region)))
+ }
+ }
+ log := captureLog(t)
+ for range 2 {
+ log.Reset()
+ if err := ConvergeDeployment(t.Context(), f, testZone, routes, bodies, "example.com"); err != nil {
+ t.Fatal(err)
+ }
+ if strings.Count(log.String(), "ERROR steering: dropped duplicate region target") != 4 {
+ t.Fatalf("want four region/winner/loser summaries, got %s", log)
+ }
+ for _, region := range []string{"us-east-1", "eu-west-1"} {
+ for _, box := range []string{"b", "c"} {
+ want := fmt.Sprintf("region=%s kept=a-%s dropped=%s-%s name_count=135 examples=\"[edge.example.com. h000.example.com. h001.example.com.]\"", region, region, box, region)
+ if strings.Count(log.String(), want) != 1 {
+ t.Fatalf("missing summary %q: %s", want, log)
+ }
+ }
+ }
+ if len(f.records) != 270 {
+ t.Fatalf("records=%d, want one per name and region", len(f.records))
+ }
+ }
+}
diff --git a/internal/steering/route53.go b/internal/steering/route53.go
index 83e06ea76..bb176a6a4 100644
--- a/internal/steering/route53.go
+++ b/internal/steering/route53.go
@@ -1045,16 +1045,32 @@ func oneTargetPerRegion(want []desiredRecord, existing []r53types.ResourceRecord
winners[key] = candidate
}
}
+ type drop struct{ region, kept, dropped string }
+ drops := make(map[drop]map[string]bool)
+ var order []drop
out := make([]desiredRecord, 0, len(want))
for _, rec := range want {
candidate := target{rec.Region, rec.Box, rec.EIP}
kept := winners[nameRegion{rec.Name, rec.Region}]
if candidate != kept {
- slog.Error("steering: dropped duplicate region target", "name", rec.Name, "region", rec.Region, "kept", kept.box, "dropped", rec.Box)
+ key := drop{rec.Region, kept.box, rec.Box}
+ if drops[key] == nil {
+ drops[key] = make(map[string]bool)
+ order = append(order, key)
+ }
+ drops[key][rec.Name] = true
continue
}
out = append(out, rec)
}
+ for _, key := range order {
+ names := make([]string, 0, len(drops[key]))
+ for name := range drops[key] {
+ names = append(names, name)
+ }
+ sort.Strings(names)
+ slog.Error("steering: dropped duplicate region target", "region", key.region, "kept", key.kept, "dropped", key.dropped, "name_count", len(names), "examples", names[:min(3, len(names))])
+ }
return out
}