carlos / platform Public

edge: grace 120 s on the probe eject; skip catch-alls (#511 R28)

Review round 1: retiredCopyGrace is 120 s. Its comment now names the
hub's probe eject (replicaProbeInterval x replicaProbeFail, plus the
first refusal) as what stops the hub sending, and the hub's reload of
the set (25 to 50 s passes on the flagship) as the backstop, not a
proven bound. hubSetReloadBound is gone. A catch-all key is never
recorded: replica rows are exact hosts, and retiring is asked with a
request's exact host.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 51ead0a1fb5849fd43c1e83840e64c7fca5908a9 parent 2a16760
2 files changed, +31 −19
  • internal/edge/retiredcopy.go +26 −17
  • internal/edge/retiredcopy_test.go +5 −2
diff --git a/internal/edge/retiredcopy.go b/internal/edge/retiredcopy.go
index 2c22c8bfe..6ec646144 100644
--- a/internal/edge/retiredcopy.go
+++ b/internal/edge/retiredcopy.go
@@ -4,29 +4,32 @@ import (
"fmt"
"log"
"net/http"
+ "strings"
"sync"
"time"
"github.com/carlosframework/platform/internal/tunnelclient"
)
-// hubSetReloadBound bounds one hub reload of a replica set: how long the
-// hub takes, after a box's copy retires, to rewrite the set's row in its
-// provision pass and load it through its registry poll (2 s). Drill 4
-// (#511) saw the dev hub rewrite the set 2 s after box-2 dropped its row,
-// and its passes about 15 s apart (17:53:40.7Z, 17:53:55.6Z). A refusal
-// ejects the copy at the hub sooner than that (R26), and the box's replica
-// probe for a host it no longer serves fails, which keeps it out.
-const hubSetReloadBound = 30 * time.Second
-
-// retiredCopyGrace is #511 R28's grace window: two hub reload intervals.
-// For this long after this box drops a replica set's row because its copy
-// is retiring (the copies lowered, or the box removed as a member), a
-// request for the host that still arrives over the fleet tunnel is refused
-// unprocessed (RST_STREAM REFUSED_STREAM) instead of answered 404, and the
-// hub serves it from a surviving copy whatever its method (R26). After it,
-// the host gets the normal unknown-host answer.
-const retiredCopyGrace = 2 * hubSetReloadBound
+// retiredCopyGrace is #511 R28's grace window. For this long after this
+// box drops a replica set's row because its copy is retiring (the copies
+// lowered, or the box removed as a member), a request for the host that
+// still arrives over the fleet tunnel is refused unprocessed (RST_STREAM
+// REFUSED_STREAM) instead of answered 404, and the hub serves it from a
+// surviving copy whatever its method (R26). After it, the host gets the
+// normal unknown-host answer.
+//
+// What actually stops the hub sending here is its replica prober, not
+// this window: the first refusal ejects the copy (R26), and the box's
+// probe for a host it no longer serves fails (replicaprobe.go,
+// replica-probe-route), so the copy is out within replicaProbeInterval x
+// replicaProbeFail (2 s) and never readmitted. The hub's own reload of
+// the set is the backstop: its provision pass rewriting the row (a 2 s
+// tick, a 5 s full-pass clamp and the pass's own length, 25 to 50 s
+// measured on the flagship) and its 2 s registry poll. None of that is a
+// proven bound, so the grace is a conservative 120 s, past two flagship
+// passes; a longer grace costs nothing once the hub has dropped the copy.
+const retiredCopyGrace = 120 * time.Second
// retiredCopies is the hosts whose replica copy this box retired within
// retiredCopyGrace, each with the time its grace ends. Only Reload writes
@@ -71,6 +74,12 @@ func (c *retiredCopies) note(prev, next map[string]upstream) []string {
if _, served := next[host]; served {
continue
}
+ // A catch-all key ("*.example.com") is never recorded: retiring
+ // is asked with a request's exact host, and replica rows are exact
+ // hosts (a set's row, and the hub's forward row, name one host).
+ if strings.HasPrefix(host, "*") {
+ continue
+ }
// The copy itself retired: its own host is gone too. A name
// dropped while the copy's row stays (an alias detached) is not a
// retiring copy.
diff --git a/internal/edge/retiredcopy_test.go b/internal/edge/retiredcopy_test.go
index 06f659b5a..61018a5ed 100644
--- a/internal/edge/retiredcopy_test.go
+++ b/internal/edge/retiredcopy_test.go
@@ -36,6 +36,7 @@ func TestRetiredCopiesNote(t *testing.T) {
prev := map[string]upstream{
"shop.example.com": {route: set},
"www.shop.example.com": {route: set, alias: true},
+ "*.shop.example.com": {route: set, alias: true},
"stays.example.com": {route: stays},
"www.stays.example": {route: stays, alias: true},
"single.example.com": {route: single},
@@ -76,7 +77,9 @@ func TestRetiredCopiesNote(t *testing.T) {
if len(c.until) != 0 {
t.Fatalf("a lapsed grace was kept: %v", c.until)
}
- if retiredCopyGrace < 2*hubSetReloadBound {
- t.Fatal("the grace is under two hub reload intervals")
+ // The probe eject is the protection; the grace outlasts it, and two
+ // flagship provision passes (25 to 50 s each) as the backstop.
+ if retiredCopyGrace <= replicaProbeInterval*replicaProbeFail || retiredCopyGrace < 2*50*time.Second {
+ t.Fatal("the grace is too short")
}
}