region HA G3-B10: create-path gates
Co-Authored-By: Astra <noreply@openai.com>
5 files changed,
+11
−11
internal/console/apiinstances.go+5 −5internal/console/apisidecars.go+2 −2internal/console/domainattach.go+1 −1internal/console/hacreate.go+1 −1internal/console/nocapacity.go+2 −2
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go| index 885d4acd3..7d7a5c4ee 100644 |
| --- a/internal/console/apiinstances.go |
| +++ b/internal/console/apiinstances.go |
| @@ -1836,7 +1836,7 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request) |
| if regionFrom == "app" { |
| // Active HA eligibility is checked from the shared observation after validation. |
| var cands []regionCandidate |
| - if !s.haRegion(region) { |
| + if !s.haCreate(region, m.Pool) { |
| snap, err := s.liveEdges(ctx) |
| if err != nil { |
| log.Printf("console: api instances create %s/%s: read edges: %v", acct.Sqid, app, err) |
| @@ -1954,7 +1954,7 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request) |
| if placed == "" && region != "" { |
| // Region HA (spec 2 §7, H27): a region with no box that has room is |
| // the no-room refusal, before this gate answers it as a 400. |
| - if !s.haRegion(region) { |
| + if !s.haCreate(region, m.Pool) { |
| if err := s.roomIn(ctx, region, m.Pool); err != nil { |
| writeClaimResponseError(w, err) |
| return false |
| @@ -2007,7 +2007,7 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request) |
| } |
| return true |
| } |
| - if !s.haRegion(region) && !checkPlacement() { |
| + if !s.haCreate(region, m.Pool) && !checkPlacement() { |
| return |
| } |
| channel := strings.TrimSpace(req.Channel) |
| @@ -2278,7 +2278,7 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request) |
| } |
| } |
| // Capacity must not hide a duplicate outside the leftover rail's scope. |
| - if s.haRegion(region) && !s.leftoverCheckApplies(region, rec.Pool) && !(s.shouldStampHA(rec) && !seeded && rec.DerivesPaths()) { |
| + if s.haCreate(region, rec.Pool) && !s.leftoverCheckApplies(region, rec.Pool) && !(s.shouldStampHA(rec) && !seeded && rec.DerivesPaths()) { |
| if _, _, err := s.readRecord(ctx, acct.Sqid, app, host); err == nil { |
| jsonError(w, http.StatusConflict, "instance "+host+" already exists") |
| return |
| @@ -2342,7 +2342,7 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request) |
| jsonError(w, ref.Status, ref.Msg) |
| return |
| } |
| - if s.haRegion(region) && !checkPlacement() { |
| + if s.haCreate(region, rec.Pool) && !checkPlacement() { |
| return |
| } |
| // Every ordinary check has passed: a seed door takes over from here, and |
diff --git a/internal/console/apisidecars.go b/internal/console/apisidecars.go| index 52427fa95..672a952d1 100644 |
| --- a/internal/console/apisidecars.go |
| +++ b/internal/console/apisidecars.go |
| @@ -366,7 +366,7 @@ func (s *Server) handleAPISidecarCreate(w http.ResponseWriter, r *http.Request) |
| // The shape rails, at the door — the same door the box's reconcile pass |
| // re-checks them at, because neither side trusts the other about what is |
| // in the bucket. The message is ValidateSidecarShape's own. |
| - rec.HA = s.haRegion(rec.Region) |
| + rec.HA = s.haCreate(rec.Region, rec.Pool) |
| if rec.HA && !m.HibernateOrDefault() { |
| jsonError(w, http.StatusBadRequest, "high availability sidecars must allow hibernation.") |
| return |
| @@ -415,7 +415,7 @@ func (s *Server) handleAPISidecarCreate(w http.ResponseWriter, r *http.Request) |
| writeDoorRefusalJSON(w, r, ref) |
| return |
| } |
| - if s.haRegion(region) && !s.leftoverCheckApplies(region, rec.Pool) { |
| + if s.haCreate(region, rec.Pool) && !s.leftoverCheckApplies(region, rec.Pool) { |
| if _, err := provision.GetSidecarRecord(ctx, s.cfg.Releases, acct.Sqid, app, name); err == nil { |
| jsonError(w, http.StatusConflict, "sidecar "+name+" already exists") |
| return |
diff --git a/internal/console/domainattach.go b/internal/console/domainattach.go| index 996018853..7ac4b18e5 100644 |
| --- a/internal/console/domainattach.go |
| +++ b/internal/console/domainattach.go |
| @@ -225,7 +225,7 @@ func (s *Server) attachDomainAs(ctx context.Context, acct *Account, app, host, k |
| if ref := s.heldElsewhere(ctx, host, acct.Sqid, app); ref != nil { |
| return attachResult{}, ref |
| } |
| - if s.haRegion("") { |
| + if s.haCreate("", "") { |
| // A standing first-route record is a reattachment, not a new create. |
| existing, _, readErr := s.readRecord(ctx, acct.Sqid, app, host) |
| if readErr != nil && !errors.Is(readErr, os.ErrNotExist) { |
diff --git a/internal/console/hacreate.go b/internal/console/hacreate.go| index 5307e77e4..f0439894c 100644 |
| --- a/internal/console/hacreate.go |
| +++ b/internal/console/hacreate.go |
| @@ -17,7 +17,7 @@ func (s *Server) haCreateShapeRefusal(rec provision.Record) *doorRefusal { |
| if rec.Demo != nil { |
| return demoDataRefusal() |
| } |
| - if s.haRegion(rec.Region) && rec.KindOrDefault() == "instance" && len(rec.AddrsOrDefault()) == 0 && rec.Runtime == "" && !rec.HibernateOrDefault() { |
| + if s.haCreate(rec.Region, rec.Pool) && rec.KindOrDefault() == "instance" && len(rec.AddrsOrDefault()) == 0 && rec.Runtime == "" && !rec.HibernateOrDefault() { |
| return &doorRefusal{Status: http.StatusBadRequest, Msg: fmt.Sprintf("%s has high availability turned on. binary socket instances must allow hibernation. resident rootfs instances are still allowed.", s.offlineName(rec.Region))} |
| } |
| return nil |
diff --git a/internal/console/nocapacity.go b/internal/console/nocapacity.go| index 3c6869719..6f11dfaf3 100644 |
| --- a/internal/console/nocapacity.go |
| +++ b/internal/console/nocapacity.go |
| @@ -46,7 +46,7 @@ const haCapacityPoolRefusal = "Capacity for pool %s in %s could not be checked. |
| // requireHACreateCapacity reads the shared observation before a new create's |
| // first mutation. It selects no executor and grants no runtime authority. |
| func (s *Server) requireHACreateCapacity(ctx context.Context, region, pool string, sidecarPlacement ...string) *doorRefusal { |
| - if !s.haRegion(region) { |
| + if !s.haCreate(region, pool) { |
| return nil |
| } |
| name := s.homeRegionOut(region) |
| @@ -169,7 +169,7 @@ func (s *Server) noRoom(ctx context.Context, region string) error { |
| } |
| }() |
| } |
| - return &noCapacityError{Region: name} |
| + return &noCapacityError{Region: s.offlinePlace(region)} |
| } |
| // placementChooser is the create door's chooser scoped as |