region HA P1a Task 13: console stamps born-HA records; HA hosts' moves and places, and imports into HA regions, refused up front
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 files changed,
+320
−13
cmd/console/haregions_test.go+19 −0cmd/console/main.go+15 −0internal/console/apiinstanceimport.go+10 −0internal/console/apiinstancemove.go+2 −2internal/console/apiinstancemove_offline.go+1 −1internal/console/apiinstances.go+6 −0internal/console/domainattach.go+2 −0internal/console/fleets.go+4 −1internal/console/ha_born_test.go+201 −0internal/console/seedmove.go+54 −9internal/console/server.go+6 −0
diff --git a/cmd/console/haregions_test.go b/cmd/console/haregions_test.go| new file mode 100644 |
| index 000000000..f142dc6e0 |
| --- /dev/null |
| +++ b/cmd/console/haregions_test.go |
| @@ -0,0 +1,19 @@ |
| +package main |
| + |
| +import ( |
| + "reflect" |
| + "testing" |
| +) |
| + |
| +func TestHARegionsList(t *testing.T) { |
| + for in, want := range map[string][]string{ |
| + "": nil, |
| + " , ": nil, |
| + "ie": {"ie"}, |
| + " ie, uk ,,x": {"ie", "uk", "x"}, |
| + } { |
| + if got := haRegionsList(in); !reflect.DeepEqual(got, want) { |
| + t.Errorf("haRegionsList(%q) = %v, want %v", in, got, want) |
| + } |
| + } |
| +} |
diff --git a/cmd/console/main.go b/cmd/console/main.go| index 4999eb450..daeb0de7b 100644 |
| --- a/cmd/console/main.go |
| +++ b/cmd/console/main.go |
| @@ -443,6 +443,8 @@ func serve() { |
| // move door's box identity check (unset: no box verifies). |
| AWSAccount: strings.TrimSpace(os.Getenv("CARLOS_AWS_ACCOUNT")), |
| AppRegions: appRegionsSwitch(os.Getenv("CONSOLE_APP_REGIONS")), |
| + // Region HA P1a: hosts created in these regions are born HA. |
| + HARegions: haRegionsList(os.Getenv("CONSOLE_HA_REGIONS")), |
| // GeoIP (geoip spec §11.3): the CONSOLE_GEOIP_DB override when set, |
| // otherwise the follower of this box's own edge mirror. |
| GeoIP: geoLocator(geoReader), |
| @@ -1551,6 +1553,19 @@ func envBytes(k string, def int64) int64 { |
| // trimmed) turns app regions on. |
| func appRegionsSwitch(v string) bool { return strings.EqualFold(strings.TrimSpace(v), "on") } |
| +// haRegionsList reads CONSOLE_HA_REGIONS: comma-separated region codes, the |
| +// regions whose new hosts are born HA (region HA P1a). Blanks are dropped; |
| +// unset is none. |
| +func haRegionsList(v string) []string { |
| + var out []string |
| + for _, r := range strings.Split(v, ",") { |
| + if r = strings.TrimSpace(r); r != "" { |
| + out = append(out, r) |
| + } |
| + } |
| + return out |
| +} |
| + |
| // openGeoIP opens the optional CONSOLE_GEOIP_DB. Unset, unopenable or not |
| // an mmdb means the IP step is off, logged once and never fatal. Returns an |
| // untyped nil on every failure, never a nil *geo.MMDB in the interface. |
diff --git a/internal/console/apiinstanceimport.go b/internal/console/apiinstanceimport.go| index caca774e4..59b33cc30 100644 |
| --- a/internal/console/apiinstanceimport.go |
| +++ b/internal/console/apiinstanceimport.go |
| @@ -115,6 +115,10 @@ func (s *Server) beginImport(w http.ResponseWriter, r *http.Request, c seedCreat |
| jsonError(w, ref.Status, ref.Msg) |
| return |
| } |
| + // RHA-P1a-C2: no import into an HA region, before any write. |
| + if s.refuseHAImport(w, c.rec.Region) { |
| + return |
| + } |
| if s.cfg.SeedData == nil || s.cfg.HibernateBucket == "" { |
| ref := seedNoDataRefusal() |
| jsonError(w, ref.Status, ref.Msg) |
| @@ -384,6 +388,9 @@ func (s *Server) handleAPIImportUpload(w http.ResponseWriter, r *http.Request) { |
| } |
| ctx := r.Context() |
| seed := rec.Seed |
| + if s.refuseHAImport(w, rec.Region) { |
| + return |
| + } |
| if ref := staleUploadRefusal(host, rec, seed.ID); ref != nil { |
| jsonError(w, ref.Status, ref.Msg) |
| return |
| @@ -708,6 +715,9 @@ func (s *Server) handleAPIImportStopped(w http.ResponseWriter, r *http.Request) |
| if !ok { |
| return |
| } |
| + if s.refuseHAImport(w, rec.Region) { |
| + return |
| + } |
| if rec.Seed.State != seeds.StateUploaded { |
| jsonError(w, http.StatusConflict, fmt.Sprintf("%s is %s. Mark it stopped once, after its upload.", host, rec.Seed.State)) |
| return |
diff --git a/internal/console/apiinstancemove.go b/internal/console/apiinstancemove.go| index 5a51c6cb9..e2d228cd6 100644 |
| --- a/internal/console/apiinstancemove.go |
| +++ b/internal/console/apiinstancemove.go |
| @@ -413,7 +413,7 @@ func (s *Server) legacyHandleAPIInstanceMoveRequest(w http.ResponseWriter, r *ht |
| if !ok { |
| return |
| } |
| - if s.refuseSeedMove(w, rec) { |
| + if s.refuseSeedMove(w, rec) || s.refuseHAMove(w, rec) { |
| return |
| } |
| // A replica is refused at the request only (G14): moveGate also fronts |
| @@ -569,7 +569,7 @@ func (s *Server) handleAPIInstanceMoveRequest(w http.ResponseWriter, r *http.Req |
| if !ok { |
| return |
| } |
| - if s.refuseSeedMove(w, rec) { |
| + if s.refuseSeedMove(w, rec) || s.refuseHAMove(w, rec) { |
| return |
| } |
| // Host-claim consoles start the move under the app's admission: the |
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go| index 21c2341c7..81b347502 100644 |
| --- a/internal/console/apiinstancemove_offline.go |
| +++ b/internal/console/apiinstancemove_offline.go |
| @@ -495,7 +495,7 @@ func (s *Server) offlineClaimEvidence(ctx context.Context, d offlineDoor) *offli |
| // claims may have changed since the stage. |
| func (s *Server) offlineBeginChecks(w http.ResponseWriter, r *http.Request, d offlineDoor) (string, offlineFleet, bool) { |
| rec, host := d.rec, d.host |
| - if s.refuseSeedMove(w, rec) { |
| + if s.refuseSeedMove(w, rec) || s.refuseHAMove(w, rec) { |
| return "", offlineFleet{}, false |
| } |
| if rec.Role != "" { |
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go| index ae0f0cb51..a62e90e91 100644 |
| --- a/internal/console/apiinstances.go |
| +++ b/internal/console/apiinstances.go |
| @@ -1775,6 +1775,12 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request) |
| rec: rec, placed: placed, regionFrom: regionFrom, siblingLabel: siblingLabel, lifetime: lifetime}, *req.Import) |
| return |
| } |
| + // Born HA (region HA P1a): only here, after the seed doors above have |
| + // taken their records, so a seed or an import is never stamped. A |
| + // replica is a copy for another region, not a home, so it is not either. |
| + if rec.Role == "" { |
| + rec.HA = s.haRegion(rec.Region) |
| + } |
| // A fresh budget for the write and its rollback: validation and the |
| // rail's listings may have spent most of the original one. |
| cancel() |
diff --git a/internal/console/domainattach.go b/internal/console/domainattach.go| index eac4f59ad..92c213ad7 100644 |
| --- a/internal/console/domainattach.go |
| +++ b/internal/console/domainattach.go |
| @@ -250,6 +250,7 @@ func (s *Server) attachDomainAs(ctx context.Context, acct *Account, app, host, k |
| Channel: channel, Kind: "static", |
| CreatedAt: time.Now().UTC(), CreatedBy: principal, |
| } |
| + rec.HA = s.haRegion(rec.Region) // born HA (region HA P1a) |
| // The primary record draws its asset generation at create, like every |
| // instance record (edge asset cache design §6). |
| if err := provision.EnsureAssetGen(&rec); err != nil { |
| @@ -675,6 +676,7 @@ func (s *Server) attachFirstRouteLocked(ctx context.Context, acct *Account, app, |
| Channel: channel, Kind: "static", |
| CreatedAt: time.Now().UTC(), CreatedBy: principal, |
| } |
| + rec.HA = s.haRegion(rec.Region) // born HA (region HA P1a) |
| ambiguous := &doorRefusal{http.StatusInternalServerError, |
| "could not declare the route for this domain — nothing was attached, try again"} |
| _, err = s.createRecordWithLifetimeLocked(ctx, rec, lifetime) |
diff --git a/internal/console/fleets.go b/internal/console/fleets.go| index 206269f4c..87f959f5d 100644 |
| --- a/internal/console/fleets.go |
| +++ b/internal/console/fleets.go |
| @@ -611,12 +611,15 @@ func (s *Server) placeAppTarget(ctx context.Context, acct *Account, app, target |
| // yet (spec §5.8) refuses it, before any write. A record that cannot be |
| // read refuses it too. SetRecordRegion refuses such a seed again under |
| // its CAS, for a record created after this read. |
| - switch block, err := placeSeedBlock(ctx, s.cfg.Releases, provision.JudgeFrom(ctx), acct.Sqid, app); { |
| + // An HA record does not move either (RHA-P1a-C1), on the same read. |
| + switch block, ha, err := placeMoveBlock(ctx, s.cfg.Releases, provision.JudgeFrom(ctx), acct.Sqid, app); { |
| case err != nil: |
| log.Printf("console: place %s/%s: read instances: %v", acct.Sqid, app, err) |
| return http.StatusBadGateway, placeSeedReadFailed |
| case block != "": |
| return http.StatusConflict, provision.SeedMoveSentence(block) |
| + case ha != nil: |
| + return http.StatusConflict, haMoveSentence(s.offlineName(ha.Region)) |
| } |
| // The store-of-record write (2026-08-06 ruling): appPlacement consults |
diff --git a/internal/console/ha_born_test.go b/internal/console/ha_born_test.go| new file mode 100644 |
| index 000000000..fcb858ad1 |
| --- /dev/null |
| +++ b/internal/console/ha_born_test.go |
| @@ -0,0 +1,201 @@ |
| +package console |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "net/http" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/release" |
| + "github.com/carlosframework/platform/internal/seeds" |
| +) |
| + |
| +// RHA-P1a-C1 and C2 as approved, for host region name "ie" / "the home region". |
| +const ( |
| + haMoveC1 = "ie has high availability turned on. offline moves into or out of it are not available yet" |
| + haImportC2 = "ie has high availability turned on. imports into it are not available yet" |
| +) |
| + |
| +// markHA writes the record's HA flag as a fixture, the way a born-HA create |
| +// leaves it. |
| +func markHA(t *testing.T, rel release.Store, acct, app, host string) { |
| + t.Helper() |
| + key := provision.RecordKey(acct, app, host) |
| + raw, etag, err := rel.Get(context.Background(), key) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var rec provision.Record |
| + if err := json.Unmarshal(raw, &rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + rec.HA = true |
| + raw, err = json.Marshal(rec) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := rel.Put(context.Background(), key, raw, etag); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| +func TestCreateStampsBornHA(t *testing.T) { |
| + fx, token := instanceFixture(t, "code-born-ha") |
| + m := offlineManifest() |
| + m.Regions, m.Pool = nil, "" |
| + enableInstances(t, fx, "shop", m) |
| + if _, err := fx.st.CreateAppIn(OpsAccountID, "shop", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + fx.srv.cfg.HARegions = []string{"ie"} |
| + u := instancesURL(fx, "bab", "shop") |
| + create := func(host, region string) *provision.Record { |
| + t.Helper() |
| + if c, _, out := rawReq(t, http.MethodPost, u, token, `{"host":"`+host+`","region":"`+region+`"}`); c != http.StatusCreated { |
| + t.Fatalf("create %s = %d %s", host, c, out) |
| + } |
| + rec, err := provision.GetRecord(context.Background(), fx.rel, "bab", "shop", host) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return rec |
| + } |
| + if rec := create("ha.shop.example.com", "ie"); !rec.HA { |
| + t.Fatal("a host created in an HA region is not stamped") |
| + } |
| + if rec := create("legacy.shop.example.com", "uk"); rec.HA { |
| + t.Fatal("stamped outside an HA region") |
| + } |
| + // The home region's records keep region "", and match by the home code. |
| + fx.srv.cfg.HomeRegion = "ie" |
| + if rec := create("home.shop.example.com", ""); rec.Region != "" || !rec.HA { |
| + t.Fatalf("home record = region %q, HA %v; want the home code to match", rec.Region, rec.HA) |
| + } |
| + fx.srv.cfg.HARegions = nil |
| + if rec := create("off.shop.example.com", "ie"); rec.HA { |
| + t.Fatal("stamped with CONSOLE_HA_REGIONS unset") |
| + } |
| +} |
| + |
| +// Seeds and sidecars are never stamped in P1a (G12), even in an HA region. |
| +func TestSeedsAndSidecarsAreNeverStampedHA(t *testing.T) { |
| + f := newFromFixture(t, 1) |
| + f.fx.srv.cfg.HomeRegion = "ie" |
| + f.fx.srv.cfg.HARegions = []string{"ie"} |
| + rec := f.copy(t, fromBody) |
| + if rec.HA { |
| + t.Fatal("a --from copy was stamped HA") |
| + } |
| + // The same console stamps a plain create, so the copy's flag is the door's. |
| + if c, _, out := rawReq(t, http.MethodPost, f.url, f.token, `{"host":"plain.shop.example.com"}`); c != http.StatusCreated { |
| + t.Fatalf("plain create = %d %s", c, out) |
| + } |
| + if plain, err := f.record(t, "plain.shop.example.com"); err != nil || !plain.HA { |
| + t.Fatalf("plain create in the HA home = %+v, %v", plain, err) |
| + } |
| + |
| + fx, token := instanceFixture(t, "code-ha-sidecar") |
| + fx.srv.cfg.HomeRegion = "ie" |
| + fx.srv.cfg.HARegions = []string{"ie"} |
| + m := titoSidecarManifest() |
| + m.Regions = nil |
| + enableSidecars(t, fx, "titogo", m) |
| + if c, _, out := rawReq(t, http.MethodPost, sidecarsURL(fx, "bab", "titogo"), token, `{"name":"bot"}`); c != http.StatusCreated { |
| + t.Fatalf("sidecar create = %d %s", c, out) |
| + } |
| + for k, v := range bucketState(t, fx.rel) { |
| + if strings.Contains(k, "sidecar") && strings.Contains(v, `"ha"`) { |
| + t.Fatalf("%s carries an ha mark: %s", k, v) |
| + } |
| + } |
| +} |
| + |
| +func TestMoveDoorsRefuseHAHostBeforeAnyWrite(t *testing.T) { |
| + for _, door := range []string{"offline start", "offline stage", "legacy move", "phase 1 move"} { |
| + t.Run(door, func(t *testing.T) { |
| + w := newOfflineWorld(t, oneEach...) |
| + if door == "phase 1 move" { |
| + enableMovesPhase1(w.fx) |
| + } |
| + markHA(t, w.fx.rel, "bab", "shop", offlineHost) |
| + path, body := "", `{"region":"uk"}` |
| + switch door { |
| + case "offline stage": |
| + path = "/stage" |
| + case "legacy move", "phase 1 move": |
| + w.base = strings.TrimSuffix(w.base, "/offline") |
| + } |
| + w.refused(http.MethodPost, path, body, http.StatusConflict, haMoveC1) |
| + }) |
| + } |
| +} |
| + |
| +// A home-region record (region "") names the console's home by its code. |
| +func TestMoveRefusalNamesTheHomeRegion(t *testing.T) { |
| + w := newOfflineWorldIn(t, "ie", "", oneEach...) |
| + markHA(t, w.fx.rel, "bab", "shop", offlineHost) |
| + w.refused(http.MethodPost, "", `{"region":"uk"}`, http.StatusConflict, haMoveC1) |
| +} |
| + |
| +func TestPlaceRefusedForAppWithHAHost(t *testing.T) { |
| + fx, token := placeSeedFixture(t, "code-place-ha") |
| + putSeededRecord(t, fx.rel, "plain.example.com", "ie", seeds.KindReplica, seeds.StatePlaced) |
| + putSeededRecord(t, fx.rel, seedMoveHost, "ie", seeds.KindReplica, seeds.StatePlaced) |
| + markHA(t, fx.rel, fx.sqid, "shop", seedMoveHost) |
| + before := bucketState(t, fx.rel) |
| + code, _, raw := rawReq(t, http.MethodPost, placeURL(fx, "shop"), token, `{"target":"fleet/pi"}`) |
| + if code != http.StatusConflict || errorText(raw) != haMoveC1 { |
| + t.Fatalf("place = %d %s", code, raw) |
| + } |
| + assertNotPlaced(t, fx, "plain.example.com", seedMoveHost) |
| + after := bucketState(t, fx.rel) |
| + if len(after) != len(before) { |
| + t.Fatalf("a refused place wrote: %d objects before, %d after", len(before), len(after)) |
| + } |
| + for k, v := range before { |
| + if after[k] != v { |
| + t.Fatalf("a refused place changed %s", k) |
| + } |
| + } |
| +} |
| + |
| +func TestImportRefusedIntoHARegionInOneBoxRegion(t *testing.T) { |
| + f := newImportFixture(t) |
| + f.fx.srv.cfg.HomeRegion = "ie" |
| + f.fx.srv.cfg.HARegions = []string{"ie"} |
| + code, out := beginImport(t, f, importHost, importSHA, 10) |
| + if code != http.StatusConflict || str(t, out, "error") != haImportC2 { |
| + t.Fatalf("begin = %d %v", code, out) |
| + } |
| + f.requireNoRecord(t, importHost) |
| + f.requireNothingUploaded(t) |
| +} |
| + |
| +// An import already begun (before the region turned HA) is refused at its |
| +// upload and stopped doors too, writing nothing. |
| +func TestImportUploadAndStoppedRefusedInHARegion(t *testing.T) { |
| + f := newImportFixture(t) |
| + code, out := beginImport(t, f, importHost, importSHA, 10) |
| + f.requireBegun(t, code, out, importHost) |
| + f.fx.srv.cfg.HomeRegion = "ie" |
| + f.fx.srv.cfg.HARegions = []string{"ie"} |
| + before := bucketState(t, f.fx.rel) |
| + if code, out, err := putImport(f, importHost, []byte("x")); err != nil || code != http.StatusConflict || str(t, out, "error") != haImportC2 { |
| + t.Fatalf("upload = %d %v, %v", code, out, err) |
| + } |
| + if c, out := postImport(t, f, importHost, "stopped"); c != http.StatusConflict || str(t, out, "error") != haImportC2 { |
| + t.Fatalf("stopped = %d %v", c, out) |
| + } |
| + after := bucketState(t, f.fx.rel) |
| + if len(after) != len(before) { |
| + t.Fatalf("a refusal wrote: %d objects before, %d after", len(before), len(after)) |
| + } |
| + for k, v := range before { |
| + if after[k] != v { |
| + t.Fatalf("a refusal changed %s", k) |
| + } |
| + } |
| +} |
diff --git a/internal/console/seedmove.go b/internal/console/seedmove.go| index f4412dcde..a666fbb07 100644 |
| --- a/internal/console/seedmove.go |
| +++ b/internal/console/seedmove.go |
| @@ -26,22 +26,64 @@ func (s *Server) refuseSeedMove(w http.ResponseWriter, rec *provision.Record) bo |
| return false |
| } |
| +// haRegion reports whether new hosts in region are born HA (region HA |
| +// P1a): the region is listed in CONSOLE_HA_REGIONS. The home region "" is |
| +// matched by the console's home code. |
| +func (s *Server) haRegion(region string) bool { |
| + if region == "" { |
| + region = s.cfg.HomeRegion |
| + } |
| + return region != "" && slices.Contains(s.cfg.HARegions, region) |
| +} |
| + |
| +// haMoveSentence is RHA-P1a-C1 (approved): name is the host's region. |
| +func haMoveSentence(name string) string { |
| + return fmt.Sprintf("%s has high availability turned on. offline moves into or out of it are not available yet", name) |
| +} |
| + |
| +// haImportSentence is RHA-P1a-C2 (approved): name is the target region. |
| +func haImportSentence(name string) string { |
| + return fmt.Sprintf("%s has high availability turned on. imports into it are not available yet", name) |
| +} |
| + |
| +// refuseHAMove answers a move of a host whose record is HA with C1, on the |
| +// record's flag alone (not a box switch). Every move door calls it straight |
| +// after refuseSeedMove, before any write. |
| +func (s *Server) refuseHAMove(w http.ResponseWriter, rec *provision.Record) bool { |
| + if rec.HA { |
| + jsonError(w, http.StatusConflict, haMoveSentence(s.offlineName(rec.Region))) |
| + return true |
| + } |
| + return false |
| +} |
| + |
| +// refuseHAImport answers an import into an HA region with C2, before any |
| +// write. region is the record's (the target) region. |
| +func (s *Server) refuseHAImport(w http.ResponseWriter, region string) bool { |
| + if s.haRegion(region) { |
| + jsonError(w, http.StatusConflict, haImportSentence(s.offlineName(region))) |
| + return true |
| + } |
| + return false |
| +} |
| + |
| // placeSeedReadFailed is carlos apps place's answer when the strict read of |
| // the app's records fails, before anything has moved. The listing after the |
| // placement is written keeps main's sentence (placeInstancesFailed). |
| const placeSeedReadFailed = "could not update this app's instances. Try again." |
| -// placeSeedBlock is carlos apps place's seed rule (preflight M8(a)): a |
| +// placeMoveBlock is carlos apps place's seed rule (preflight M8(a)): a |
| // place re-homes every record of the app, so it is a move of each. It reads |
| // the app's records strictly, under judge (a record its slot no longer |
| // vouches for is not one of them; nil reads as today), and returns the first record's MoveBlock, "" |
| -// when none blocks. A record it cannot read could be anything, so it is an |
| +// when none blocks, and the first record that is HA (nil when none is): |
| +// a place re-homes it, and an HA host does not move. A record it cannot read could be anything, so it is an |
| // error and the place is refused. A record deleted between the listing and |
| // its read (the race the place's own walk skips) is read again once. |
| // |
| // No cap: the place walks every record of the app, and a cap would refuse |
| // a large app's place for good. |
| -func placeSeedBlock(ctx context.Context, st release.Store, judge *provision.LifetimeJudge, acct, app string) (string, error) { |
| +func placeMoveBlock(ctx context.Context, st release.Store, judge *provision.LifetimeJudge, acct, app string) (seed string, ha *provision.Record, err error) { |
| ctx, cancel := context.WithTimeout(ctx, instanceStoreTimeout) |
| defer cancel() |
| recs, unreadable, err := provision.ListRecordsStrictJudged(ctx, st, judge, acct, app, math.MaxInt) |
| @@ -49,7 +91,7 @@ func placeSeedBlock(ctx context.Context, st release.Store, judge *provision.Life |
| recs, unreadable, err = provision.ListRecordsStrictJudged(ctx, st, judge, acct, app, math.MaxInt) |
| } |
| if err != nil { |
| - return "", err |
| + return "", nil, err |
| } |
| if len(unreadable) > 0 { |
| hosts := make([]string, 0, len(unreadable)) |
| @@ -57,14 +99,17 @@ func placeSeedBlock(ctx context.Context, st release.Store, judge *provision.Life |
| hosts = append(hosts, h) |
| } |
| slices.Sort(hosts) |
| - return "", fmt.Errorf("records that do not read: %v", hosts) |
| + return "", nil, fmt.Errorf("records that do not read: %v", hosts) |
| } |
| - for _, rec := range recs { |
| - if b := rec.Seed.MoveBlock(); b != "" { |
| - return b, nil |
| + for i := range recs { |
| + if b := recs[i].Seed.MoveBlock(); b != "" { |
| + return b, nil, nil |
| + } |
| + if recs[i].HA && ha == nil { |
| + ha = &recs[i] |
| } |
| } |
| - return "", nil |
| + return "", ha, nil |
| } |
| // seedMoveConflict is the sentence of a write the record's seed refused |
diff --git a/internal/console/server.go b/internal/console/server.go| index 72027db93..1b862f85b 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -546,6 +546,12 @@ type Config struct { |
| // and nothing about placement changes when it is set. "" is legal: the |
| // regions endpoint then reports no home row and an empty default. |
| HomeRegion string |
| + // HARegions is CONSOLE_HA_REGIONS (region HA P1a): the region codes whose |
| + // new instance records are born HA (provision.Record.HA). The home |
| + // region matches by its code (HomeRegion), as records for it keep "". |
| + // Seeds, imports and sidecars are never stamped, and an HA host's moves |
| + // and places, and imports into an HA region, are refused up front. |
| + HARegions []string |
| // AppRegions is CONSOLE_APP_REGIONS=on (nearest-region spec §5.6). Off |
| // never stops the create door's fill for rows already holding a region. |
| AppRegions bool |