carlos / platform Public

fix: forward outside the pool after startup release obligations

Co-Authored-By: GPT-6 Astra <noreply@openai.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev b0093ac74b7f96f0a825eecda9d9316a638d7bba parent c4b2fef
2 files changed, +45 −0
  • internal/activator/haleaseloss.go +9 −0
  • internal/activator/haleaseloss_test.go +36 −0
diff --git a/internal/activator/haleaseloss.go b/internal/activator/haleaseloss.go
index 835386872..3bb80b69e 100644
--- a/internal/activator/haleaseloss.go
+++ b/internal/activator/haleaseloss.go
@@ -100,6 +100,15 @@ func (a *Service) haLeaseRefusalLocked(rt registry.Route) error {
a.latchHALossLocked(e)
}
}
+ if !a.LocalEligible(rt) {
+ if l := a.haLoss.hosts[rt.Host]; l != nil && l.old == nil && l.recovery == nil && !l.running {
+ delete(a.haLoss.hosts, rt.Host)
+ }
+ if a.haLoss.hosts[rt.Host] != nil {
+ return ErrHALeaseUnavailable
+ }
+ return nil
+ }
if a.haLoss.hosts[rt.Host] != nil {
return ErrHALeaseUnavailable
}
diff --git a/internal/activator/haleaseloss_test.go b/internal/activator/haleaseloss_test.go
index c707d755d..a5727d5f5 100644
--- a/internal/activator/haleaseloss_test.go
+++ b/internal/activator/haleaseloss_test.go
@@ -721,3 +721,39 @@ func TestHALostRecoveryFailedPostCheckStopsEntry(t *testing.T) {
}
assertLossLatched(t, s)
}
+
+func TestHALostRestartOutsidePoolForwardsAfterOwedRelease(t *testing.T) {
+ for _, latched := range []bool{false, true} {
+ t.Run(fmt.Sprint(latched), func(t *testing.T) {
+ s, e, r := lostTestEntry(t)
+ s.failMarkerPuts(1)
+ finishLostTestEntry(t, s, e, r)
+ s2 := s.restart(t)
+ if len(lease.PendingObligations()) != 1 {
+ t.Fatal("missing startup obligation")
+ }
+ if latched {
+ s2.a.mu.Lock()
+ _ = s2.a.haLeaseRefusalLocked(s2.rt)
+ s2.a.mu.Unlock()
+ }
+ s2.b.ServedPools = func() edgesfile.PoolEvidence { return edgesfile.PoolEvidence(`["another-pool"]`) }
+ s2.a.retryOwedMarkers()
+ deadline := time.Now().Add(3 * time.Second)
+ for s2.a.markers.running.Load() && time.Now().Before(deadline) {
+ time.Sleep(time.Millisecond)
+ }
+ if s2.a.markers.running.Load() || len(lease.PendingObligations()) != 0 {
+ t.Fatal("owed release did not settle")
+ }
+ putLockFor(t, s2.b, s2.rt, leaseBody(t, heldByB, time.Now().Add(time.Minute)))
+ before := len(lockWriteLogOf(s2))
+ if d := s2.a.ForwardTarget(t.Context(), s2.rt, nil); d.Ref != "b" || d.Unavailable {
+ t.Fatalf("ineligible restarted ingress: %+v", d)
+ }
+ if len(lockWriteLogOf(s2)) != before || s2.a.entries[s2.rt.Host] != nil {
+ t.Fatal("ineligible ingress acquired or woke locally")
+ }
+ })
+ }
+}