carlos / platform Public

ha: distinguish route identity drift from pool ineligibility

Co-Authored-By: GPT-6 Astra <noreply@openai.com>
claude agent, operated by paul@keymail.dev b25a4c0b6c886ecd64da1c056f1864da6057eae7 parent 251448b
4 files changed, +37 −2
  • internal/activator/activator.go +1 −1
  • internal/activator/ha_pool_test.go +33 −0
  • internal/activator/haforward.go +2 −0
  • internal/activator/heldlegs.go +1 −1
diff --git a/internal/activator/activator.go b/internal/activator/activator.go
index e66ed4ec6..e4830201b 100644
--- a/internal/activator/activator.go
+++ b/internal/activator/activator.go
@@ -1769,7 +1769,7 @@ func (a *Service) begin(ctx context.Context, rt registry.Route, stamp bool, req
e := a.entries[rt.Host]
if e != nil && !samePoolRoute(e, rt) {
a.mu.Unlock()
- return nil, &errLeaseRefused{reason: hafresh.ReasonPoolIneligible}
+ return nil, &errLeaseRefused{reason: reasonRouteIdentityChanged}
}
if !a.TenantAdmitted() && !a.TenantAdmissionExempt(rt) {
a.mu.Unlock()
diff --git a/internal/activator/ha_pool_test.go b/internal/activator/ha_pool_test.go
index 6bcaddcab..716cde1f1 100644
--- a/internal/activator/ha_pool_test.go
+++ b/internal/activator/ha_pool_test.go
@@ -2,6 +2,7 @@ package activator
import (
"context"
+ "errors"
"github.com/carlosframework/platform/internal/boxchoice"
"github.com/carlosframework/platform/internal/edgesfile"
"github.com/carlosframework/platform/internal/hafresh"
@@ -163,3 +164,35 @@ func TestPoolGateExpiredOwnerNeedsEligibleReceiver(t *testing.T) {
}
}
}
+
+func TestPoolGateRouteIdentityDrift(t *testing.T) {
+ for _, field := range []string{"pool", "region", "incarnation", "serving-seq"} {
+ t.Run(field, func(t *testing.T) {
+ s, e := haServiceEntry(t, "shop.example.com")
+ t.Cleanup(func() { s.stopForTest(e) })
+ rt := s.rt
+ switch field {
+ case "pool":
+ rt.Pool = "changed"
+ case "region":
+ rt.Region = "changed"
+ case "incarnation":
+ rt.Incarnation++
+ case "serving-seq":
+ rt.ServingSeq++
+ }
+ s.b.ServedPools = func() edgesfile.PoolEvidence { return edgesfile.PoolEvidence(`["","changed"]`) }
+ if !s.a.LocalEligible(rt) {
+ t.Fatal("fixture is not eligible")
+ }
+ _, beginErr := s.a.beginRequest(t.Context(), rt)
+ _, heldErr := s.a.AdmitHeldLeg(t.Context(), rt)
+ for _, err := range []error{beginErr, heldErr} {
+ var refused *errLeaseRefused
+ if !errors.As(err, &refused) || refused.reason != "ha_route_identity_changed" {
+ t.Fatalf("identity drift reason: %v", err)
+ }
+ }
+ })
+ }
+}
diff --git a/internal/activator/haforward.go b/internal/activator/haforward.go
index 9fd66d6d7..f484dcf6a 100644
--- a/internal/activator/haforward.go
+++ b/internal/activator/haforward.go
@@ -328,6 +328,8 @@ func (a *Service) LocalEligible(rt registry.Route) bool {
return true
}
+const reasonRouteIdentityChanged = "ha_route_identity_changed"
+
func samePoolRoute(e *actEntry, rt registry.Route) bool {
return e != nil && e.route.Host == rt.Host && e.route.Account == rt.Account && e.route.App == rt.App && e.route.Pool == rt.Pool && e.route.Region == rt.Region && e.route.Incarnation == rt.Incarnation && e.route.ServingSeq == rt.ServingSeq
}
diff --git a/internal/activator/heldlegs.go b/internal/activator/heldlegs.go
index e20ddd725..ce4d16f28 100644
--- a/internal/activator/heldlegs.go
+++ b/internal/activator/heldlegs.go
@@ -251,7 +251,7 @@ func (a *Service) admitPassThrough(ctx context.Context, rt registry.Route, onAdm
e := a.entries[rt.Host]
if e != nil && !samePoolRoute(e, rt) {
a.mu.Unlock()
- return &errLeaseRefused{reason: hafresh.ReasonPoolIneligible}
+ return &errLeaseRefused{reason: reasonRouteIdentityChanged}
}
if a.passThroughAdmissibleLocked(e) {
var err error