carlos / platform Public

console: one stateless publication check, plus fleet growth stop

Trimmed guard for #1008 after Astra round 1 (release manager's scope):
- statelessPublicationRefusal wraps the runtime floor and the unlabelled
  multi-box check, and every door that selects a stateless build asks
  it: API and browser promote, new canary, rollback and fast-track
  (statelessVersionRefusal), instance create. Hibernating stateless
  builds are included; their wake needs the coordinator too.
- A --stateless ship is refused before upload, hibernating or not.
- fleetGrowthRefusal: add-box (which also reactivates) is refused when
  it would take a fleet past one active box while an unlabelled
  instance of it runs a stateless build; reads it can't finish give a
  503.
- The copies-publication change of the first commit is reverted; copies
  above 1 keep the count-path check.

Witness TestNoTransitionCutsOffAStatelessInstance (invariant): from
three worlds, after every accepted ship, promote, rollback, copies 2,
reactivate or add-box, no stateless instance is left refused by every
fleet box, and the labelled control refuses nothing. With the guard
disabled it fails on promote, rollback, reactivate and add-box.
TestStatelessPublicationCoversHibernating. Drafts SR-5-C01 and SR-5-C02
await Paul's copy review. Pin, instance channel set and unlabelled
creates are left to the label backfill (#1008 option B).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev d0ff269a0002a25c3f655f1afeadc1cac32f92bd parent a0d0917
10 files changed, +241 −70
  • docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md +1 −0
  • internal/console/apicli.go +3 −3
  • internal/console/apiinstances.go +2 −2
  • internal/console/appcopies.go +91 −2
  • internal/console/copiespublication.go +4 −11
  • internal/console/copiespublication_test.go +3 −9
  • internal/console/copiesunlabelled_test.go +127 −40
  • internal/console/fleets.go +7 −0
  • internal/console/rootfs.go +1 −1
  • internal/console/server.go +2 −2

CI failed — run details

Intent

Human

<task-notification> <task-id>bibhgeh7y</task-id> <tool-use-id>toolu_01NK4tCC8GKskrs66mLRCih9</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/bibhgeh7y.output</output-file> <status>completed</status> <summary>Background command "Run Astra's review of the guard" completed (exit code 0)</summary> </task-notification>

Human

<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="0ee72b11-982f-44cf-b028-6349332711e1"> Agent manager 8a3d302: your recommendation: B as the real fix (spec first: backfill from the hub&apos;s current binding so no live app changes box, no unlabelled creates on multi-box fleets, rollout plan + dev drill; Astra on the spec), and a TRIMMED A now. Trimmed A = every stateless target incl. hibernating, at the one shared publication function plus ship, regardless of copies, plus ONE more cheap stop: refuse add-box/reactivate while the fleet holds an unlabelled stateless instance (that&apos;s the only way a working instance breaks without any stateless action). Prefer an invariant test over per-door examples (memory invariant-simulations-over-example-fixes): for every accepted transition in the test world, no stateless instance is refused by every fleet box. One Astra round on trimmed A; the remaining doors are covered by B. </paseo-system>

Human

<task-notification> <task-id>ba67ij8mn</task-id> <tool-use-id>toolu_01F78L3wUDYVcNsAo6nijuqy</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/ba67ij8mn.output</output-file> <status>completed</status> <summary>Background command "Report the guard's P1 and options to 8a3d302" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>bu3uiqh1t</task-id> <tool-use-id>toolu_01Cuie8ceNuAG8rZLZqSqaLg</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/bu3uiqh1t.output</output-file> <status>completed</status> <summary>Background command "Wait for CI on the guard" completed (exit code 0)</summary> </task-notification>

Human

Go ahead

diff --git a/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md b/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md
index dcf31a9f3..65a89e04b 100644
--- a/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md
+++ b/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md
@@ -167,3 +167,4 @@ copy too. Internal wire enums are not an excuse to expose unreviewed text.
| SR-4-C93 | docs/site/stateless-replicas.md | An app that creates its own instance.key or report.token file must take those values from a shared source, its configuration or its environment, or run one copy. The platform gives every copy the same CARLOS_INSTANCE_KEY, but it cannot stop each copy of an app from writing a different file of its own. | approved (controller; Luna house rules) (drill 1 round 2, A3 restriction) |
| SR-4-C94 | docs/site/stateless-replicas.md | When a copy switches, its old build stops once the new one serves. A response still streaming from the old build when it stops is cut, as when a box stops. Websockets on the old build disconnect and their clients reconnect to a healthy copy. | approved (controller; Luna house rules) (drill 3, H4) |
| SR-5-C01 | internal/console/appcopies.go | <host> is not tied to one box of fleet <fleet>, and that fleet has more than one box. a release without a local database needs that first, so keep this app on a release with a local database for now | DRAFT, awaiting Paul's copy review (#1008; refused at ship, at any publication of a stateless build, and at copies above 1) |
+| SR-5-C02 | internal/console/appcopies.go | <host> runs a release without a local database and is not tied to a box of fleet <fleet>, so a second active box would stop it. move it to a release with a local database before adding a box | DRAFT, awaiting Paul's copy review (#1008; refused at fleet add-box and box reactivation) |
diff --git a/internal/console/apicli.go b/internal/console/apicli.go
index c9536ef81..690a744c1 100644
--- a/internal/console/apicli.go
+++ b/internal/console/apicli.go
@@ -1037,7 +1037,7 @@ func (s *Server) handleAPIPromote(w http.ResponseWriter, r *http.Request) {
jsonError(w, ref.Status, ref.Msg)
return
}
- if ref := s.statelessRuntimeRefusal(ctx, channel, man, nil, ""); ref != nil {
+ if ref := s.statelessPublicationRefusal(ctx, acct.Sqid, app, channel, man, nil, ""); ref != nil {
jsonError(w, ref.Status, ref.Msg)
return
}
@@ -2341,8 +2341,8 @@ func (s *Server) handleAPIShip(w http.ResponseWriter, r *http.Request) {
}
// A stateless build an instance of this app could never wake is
// refused before anything is uploaded (#1008).
- if meta.Stateless && !meta.Hibernate {
- if ref := s.unlabelledFleetRefusal(r.Context(), acct, app); ref != nil {
+ if meta.Stateless {
+ if ref := s.unlabelledFleetRefusal(r.Context(), acct.Sqid, app); ref != nil {
writeDoorRefusal(w, ref)
return
}
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go
index 797be8a7a..1861a84a6 100644
--- a/internal/console/apiinstances.go
+++ b/internal/console/apiinstances.go
@@ -2189,7 +2189,7 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request)
return
}
if chHead != nil {
- if ref := s.statelessRuntimeRefusal(ctx, channel, chHead.Manifest, nil, ""); ref != nil {
+ if ref := s.statelessPublicationRefusal(ctx, acct.Sqid, app, channel, chHead.Manifest, nil, ""); ref != nil {
jsonError(w, ref.Status, ref.Msg)
return
}
@@ -2511,7 +2511,7 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request)
if fleetActive != nil && fleetLabelsRecord(rec) && movable(rec) {
if box := fleetActive.chooseDestination(rec.Runtime == provision.RuntimeRootfsV1, ""); box != "" {
if chHead != nil {
- if ref := s.statelessRuntimeRefusal(ctx, channel, chHead.Manifest, fleetActive, box); ref != nil {
+ if ref := s.statelessPublicationRefusal(ctx, acct.Sqid, app, channel, chHead.Manifest, fleetActive, box); ref != nil {
jsonError(w, ref.Status, ref.Msg)
return
}
diff --git a/internal/console/appcopies.go b/internal/console/appcopies.go
index ffc6ae94a..638db3770 100644
--- a/internal/console/appcopies.go
+++ b/internal/console/appcopies.go
@@ -21,6 +21,8 @@ import (
const (
copiesStopping = "copies are still stopping on other boxes. wait for that to finish before selecting a release with a local database"
+ // copiesUnlabelledGrowth (#1008, draft for copy review): host, fleet.
+ copiesUnlabelledGrowth = "%s runs a release without a local database and is not tied to a box of fleet %s, so a second active box would stop it. move it to a release with a local database before adding a box"
// copiesUnlabelled (#1008, draft for copy review): host, fleet.
copiesUnlabelled = "%s is not tied to one box of fleet %s, and that fleet has more than one box. a release without a local database needs that first, so keep this app on a release with a local database for now"
copiesBounds = "copies must be a whole number of at least 1"
@@ -430,6 +432,21 @@ func (s *Server) copiesSizeRefusal(ctx context.Context, acct *Account, app strin
return nil
}
+// statelessPublicationRefusal is the check every door that selects a
+// stateless build for an app's instances asks (promote, new canary,
+// rollback, fast-track, instance create): the runtime floor, then
+// unlabelledFleetRefusal (#1008). Hibernating stateless builds included:
+// their wake needs the coordinator too.
+func (s *Server) statelessPublicationRefusal(ctx context.Context, sqid, app, channel string, m *release.Manifest, fleet *fleetView, box string) *doorRefusal {
+ if ref := s.statelessRuntimeRefusal(ctx, channel, m, fleet, box); ref != nil {
+ return ref
+ }
+ if m == nil || !m.Stateless {
+ return nil
+ }
+ return s.unlabelledFleetRefusal(ctx, sqid, app)
+}
+
// unlabelledFleetRefusal refuses a release without a local database, or
// more than one copy, for an app with a live instance whose record is
// placed on a fleet but tied to no box (no fleet_box, no replica
@@ -439,8 +456,8 @@ func (s *Server) copiesSizeRefusal(ctx context.Context, acct *Account, app strin
// (replicaFleetRecord's sole-box rule), refusing every box otherwise: a
// stateless build of it could never wake. Refused here, before anything is
// published, rather than left to fail at the next wake.
-func (s *Server) unlabelledFleetRefusal(ctx context.Context, acct *Account, app string) *doorRefusal {
- recs, err := placeRecords(ctx, s.cfg.Releases, provision.JudgeFrom(ctx), acct.Sqid, app)
+func (s *Server) unlabelledFleetRefusal(ctx context.Context, sqid, app string) *doorRefusal {
+ recs, err := placeRecords(ctx, s.cfg.Releases, provision.JudgeFrom(ctx), sqid, app)
if err != nil {
return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: copiesUnread}
}
@@ -491,3 +508,75 @@ func unlabelledFleetRecordRefusal(reg consoleRegistry, recs []provision.Record)
}
return nil
}
+
+// fleetGrowthRefusal refuses adding or reactivating label on fleet when that
+// would take the fleet from at most one active box to more than one while
+// an unlabelled instance of the fleet runs a stateless build (#1008): the
+// coordinator door accepts such a record only on a one-box fleet, so the
+// growth alone would cut it off. Reads it can't finish answer 503.
+func (s *Server) fleetGrowthRefusal(ctx context.Context, reg consoleRegistry, acct *Account, fleet, label string) *doorRefusal {
+ unread := &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgFleetBoxNotAdded}
+ boxes, err := reg.ListFleetBoxes(fleet)
+ if err != nil {
+ return unread
+ }
+ active := 0
+ for _, b := range boxes {
+ if b.Status == "active" {
+ if b.Label == label {
+ return nil // already active: not growth (the door answers the duplicate)
+ }
+ active++
+ }
+ }
+ if active+1 <= 1 || s.cfg.Releases == nil {
+ return nil
+ }
+ apps, err := s.store.AppsIn(acct.ID)
+ if err != nil {
+ return unread
+ }
+ for _, app := range apps {
+ recs, err := placeRecords(ctx, s.cfg.Releases, provision.JudgeFrom(ctx), acct.Sqid, app)
+ if err != nil {
+ return unread
+ }
+ for _, rec := range recs {
+ if rec.Retired || rec.Region != "fleet/"+fleet || rec.FleetBox != "" || rec.ReplicaAssignment != nil {
+ continue
+ }
+ stateless, err := s.channelHeadStateless(ctx, acct.Sqid, app, rec.Channel)
+ if err != nil {
+ return unread
+ }
+ if stateless {
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(copiesUnlabelledGrowth, rec.Host, fleet)}
+ }
+ }
+ }
+ return nil
+}
+
+// channelHeadStateless reports whether channel's current build declares no
+// local database. No channel, or an empty one, is false; a read that
+// fails is an error, never false.
+func (s *Server) channelHeadStateless(ctx context.Context, sqid, app, channel string) (bool, error) {
+ if channel == "" {
+ return false, nil
+ }
+ ptr, err := release.Channel(ctx, s.cfg.Releases, s.cfg.ReleasePub, sqid, app, channel)
+ if errors.Is(err, os.ErrNotExist) {
+ return false, nil
+ }
+ if err != nil {
+ return false, err
+ }
+ if ptr == nil || ptr.Version == "" {
+ return false, nil
+ }
+ m, err := release.GetManifest(ctx, s.cfg.Releases, sqid, app, ptr.Version)
+ if err != nil {
+ return false, err
+ }
+ return m != nil && m.Stateless, nil
+}
diff --git a/internal/console/copiespublication.go b/internal/console/copiespublication.go
index e95f46085..0040d113e 100644
--- a/internal/console/copiespublication.go
+++ b/internal/console/copiespublication.go
@@ -147,22 +147,15 @@ func (s *Server) copiesPublicationRefusal(ctx context.Context, acct *Account, ap
if ship && target != nil && !target.Hibernate {
return nil
}
+ cfg, err := s.copiesDefault(ctx, acct.Sqid, app)
+ if err == nil && !cfg.explicit {
+ return nil
+ }
if target == nil && ver != "" {
target, _ = memoize(ctx, "stateless-manifest:"+release.ManifestKey(acct.Sqid, app, ver), func() (*release.Manifest, error) {
return release.GetManifest(ctx, s.cfg.Releases, acct.Sqid, app, ver)
})
}
- // Whatever the app's copies: a stateless build an instance of it could
- // never wake is refused before it is published (#1008).
- if safeCopiesTarget(target) {
- if ref := s.unlabelledFleetRefusal(ctx, acct, app); ref != nil {
- return ref
- }
- }
- cfg, err := s.copiesDefault(ctx, acct.Sqid, app)
- if err == nil && !cfg.explicit {
- return nil
- }
if err != nil {
if safeCopiesTarget(target) {
return nil
diff --git a/internal/console/copiespublication_test.go b/internal/console/copiespublication_test.go
index dc226cda1..ba4544803 100644
--- a/internal/console/copiespublication_test.go
+++ b/internal/console/copiespublication_test.go
@@ -175,10 +175,7 @@ func TestCopiesPublicationEvidence(t *testing.T) {
{"unread config unsafe", false, false, "config", 503},
{"unread config safe", false, true, "config", 200},
{"unread inventory unsafe", true, false, "record", 503},
- // A stateless target reads the inventory for #1008's guard (an
- // unlabelled record on a multi-box fleet), and an unreadable one
- // refuses with a retry rather than publish unchecked.
- {"unread inventory safe", true, true, "record", 503},
+ {"unread inventory safe", true, true, "record", 200},
} {
t.Run(tc.name, func(t *testing.T) {
fx, token := copiesWorld(t)
@@ -213,11 +210,8 @@ func TestCopiesPublicationEvidence(t *testing.T) {
if counter.gets[cfgKey] != 1 {
t.Fatalf("config GETs=%d, want exactly one", counter.gets[cfgKey])
}
- if !tc.explicit && !tc.safe && counter.gets[recKey] != 0 {
- t.Fatal("legacy target read assignments")
- }
- if tc.safe && tc.failure != "record" && counter.gets[recKey] == 0 {
- t.Fatal("stateless target published without reading the inventory (#1008)")
+ if (!tc.explicit || tc.safe) && counter.gets[recKey] != 0 {
+ t.Fatal("legacy/safe target read assignments")
}
})
}
diff --git a/internal/console/copiesunlabelled_test.go b/internal/console/copiesunlabelled_test.go
index 6920fbfb1..09fd1a368 100644
--- a/internal/console/copiesunlabelled_test.go
+++ b/internal/console/copiesunlabelled_test.go
@@ -1,35 +1,83 @@
package console
import (
+ "context"
"fmt"
+ "net/http"
"strings"
"testing"
"github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/release"
)
-// TestStatelessRefusedOnUnlabelledMultiBoxRecord (#1008): an instance whose
-// record is on a fleet but tied to no box (no fleet_box, no replica
-// assignment) is served by every box of the fleet, and the coordinator door
-// refuses it on a fleet with more than one active box, so a stateless build
-// of it could never wake. A --stateless ship, a stateless promote and
-// copies above 1 are refused up front. Controls: the same record on a
-// one-box fleet, and labelled records on the two-box fleet, are admitted.
-func TestStatelessRefusedOnUnlabelledMultiBoxRecord(t *testing.T) {
- type world struct {
- name string
- setup func(t *testing.T, fx *consoleFixture)
- refused bool
+// unlabelledStatelessCutOff lists the instances of shop that no box of fleet
+// pi could ever coordinate (#1008): live, on the fleet, tied to no box (no
+// fleet_box, no replica assignment), on a fleet with more than one active box
+// (the coordinator door's sole-box rule refuses every box), while their
+// channel's current build declares no local database.
+func unlabelledStatelessCutOff(t *testing.T, fx *consoleFixture) []string {
+ t.Helper()
+ ctx := context.Background()
+ reg := openTestReg(t, fx)
+ defer reg.Close()
+ boxes, err := reg.ListFleetBoxes("pi")
+ if err != nil {
+ t.Fatal(err)
+ }
+ active := 0
+ for _, b := range boxes {
+ if b.Status == "active" {
+ active++
+ }
}
+ recs, err := placeRecords(ctx, fx.rel, nil, fx.sqid, "shop")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var out []string
+ for _, rec := range recs {
+ if rec.Retired || rec.Region != "fleet/pi" || rec.FleetBox != "" || rec.ReplicaAssignment != nil || active <= 1 {
+ continue
+ }
+ stateless, err := fx.srv.channelHeadStateless(ctx, fx.sqid, "shop", rec.Channel)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if stateless {
+ out = append(out, rec.Host)
+ }
+ }
+ return out
+}
+
+// TestNoTransitionCutsOffAStatelessInstance (#1008, invariant): from each
+// starting world, every transition the console ACCEPTS leaves no stateless
+// instance that every fleet box would be refused (unlabelledStatelessCutOff
+// is empty). The transitions are the trimmed guard's doors: a --stateless
+// ship, a stateless promote, a rollback onto a stateless build, copies 2,
+// and adding or reactivating a box. The labelled world is the control:
+// there the guard refuses nothing.
+func TestNoTransitionCutsOffAStatelessInstance(t *testing.T) {
unlabel := func(t *testing.T, fx *consoleFixture) {
placementEdit(t, fx, "a.example.com", func(r *provision.Record) { r.FleetBox, r.FleetBoxAt = "", "" })
}
+ type world struct {
+ name string
+ setup func(t *testing.T, fx *consoleFixture)
+ // guarded worlds expect some refusal; the control expects none.
+ control bool
+ }
worlds := []world{
- {"unlabelled on a two-box fleet", unlabel, true},
- {"unlabelled on a one-box fleet", func(t *testing.T, fx *consoleFixture) {
+ {"two boxes, unlabelled, edge on a local-database build", func(t *testing.T, fx *consoleFixture) {
+ unlabel(t, fx)
+ shipVersion(t, fx, "shop", "s1")
+ if err := release.Promote(context.Background(), fx.rel, fx.priv, fx.sqid, "shop", "edge", "s1"); err != nil {
+ t.Fatal(err)
+ }
+ }, false},
+ {"one box, unlabelled, edge stateless and working", func(t *testing.T, fx *consoleFixture) {
unlabel(t, fx)
- // b.example.com moves to pi-1 so the fleet's one active box
- // still holds every labelled record.
placementEdit(t, fx, "b.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" })
reg := openTestReg(t, fx)
defer reg.Close()
@@ -37,40 +85,79 @@ func TestStatelessRefusedOnUnlabelledMultiBoxRecord(t *testing.T) {
t.Fatal(err)
}
}, false},
- {"labelled on a two-box fleet", func(*testing.T, *consoleFixture) {}, false},
+ {"two boxes, labelled", func(*testing.T, *consoleFixture) {}, true},
+ }
+ type transition struct {
+ name string
+ do func(t *testing.T, fx *consoleFixture, token string) (int, string)
+ }
+ api := func(method, path, body string) func(*testing.T, *consoleFixture, string) (int, string) {
+ return func(t *testing.T, fx *consoleFixture, token string) (int, string) {
+ return copiesCall(t, fx, token, copiesDoor{path, method, path, body})
+ }
+ }
+ addBox := func(label string) func(*testing.T, *consoleFixture, string) (int, string) {
+ return func(t *testing.T, fx *consoleFixture, token string) (int, string) {
+ code, body := postJSON(t, fleetsURL(fx, fx.sqid)+"/pi/boxes", map[string]string{"label": label}, token)
+ return code, fmt.Sprint(body)
+ }
+ }
+ transitions := []transition{
+ {"ship stateless", func(t *testing.T, fx *consoleFixture, token string) (int, string) {
+ code, body := postShip(t, fx.ts.URL+"/api/cli/apps/"+fx.sqid+"/shop/releases", token, []shipPart{metaStateless(t, "v3"), {name: "linux-amd64", body: tinyProgramForConsole(t, "example.com/shop")}})
+ return code, fmt.Sprint(body)
+ }},
+ {"promote stateless onto edge", api("POST", "/promote", `{"channel":"edge","version":"v2","hotfix":true}`)},
+ {"rollback edge", api("POST", "/rollback", `{"channel":"edge"}`)},
+ {"copies 2", func(t *testing.T, fx *consoleFixture, token string) (int, string) {
+ return copiesPut(t, fx, token, `{"copies":2}`)
+ }},
+ {"reactivate pi-2", addBox("pi-2")},
+ {"add pi-3", addBox("pi-3")},
}
- want := fmt.Sprintf(copiesUnlabelled, "a.example.com", "pi")
for _, w := range worlds {
- for _, door := range []string{"ship", "promote", "copies"} {
- if door == "copies" && strings.Contains(w.name, "one-box") {
- continue // two copies need two boxes: a capacity refusal, not this one
- }
- t.Run(w.name+"/"+door, func(t *testing.T) {
+ refusedAny := false
+ for _, tr := range transitions {
+ t.Run(w.name+"/"+tr.name, func(t *testing.T) {
fx, token := copiesWorld(t)
w.setup(t, fx)
- var code int
- var out string
- switch door {
- case "ship":
- var body map[string]any
- code, body = postShip(t, fx.ts.URL+"/api/cli/apps/"+fx.sqid+"/shop/releases", token, []shipPart{metaStateless(t, "v3"), {name: "linux-amd64", body: tinyProgramForConsole(t, "example.com/shop")}})
- out = fmt.Sprint(body)
- case "promote":
- code, out = copiesCall(t, fx, token, copiesDoor{"promote", "POST", "/promote", `{"channel":"canary/new","version":"v2"}`})
- case "copies":
- code, out = copiesPut(t, fx, token, `{"copies":2}`)
+ if cut := unlabelledStatelessCutOff(t, fx); len(cut) != 0 {
+ t.Fatalf("world starts broken: %v", cut)
}
- if w.refused {
- if code != 409 || !strings.Contains(out, want) {
- t.Fatalf("%s: %d %s, want 409 %q", door, code, out, want)
+ code, out := tr.do(t, fx, token)
+ ours := strings.Contains(out, "is not tied to") && code == http.StatusConflict
+ if ours {
+ refusedAny = true
+ if w.control {
+ t.Fatalf("control world refused: %d %s", code, out)
}
- return
}
- if code >= 300 || strings.Contains(out, "is not tied to one box") {
- t.Fatalf("%s admitted world refused: %d %s", door, code, out)
+ if code < 300 {
+ if cut := unlabelledStatelessCutOff(t, fx); len(cut) != 0 {
+ t.Fatalf("accepted %d %s, and left %v cut off from every box", code, out, cut)
+ }
}
})
}
+ if !w.control && !refusedAny {
+ t.Errorf("%s: the guard refused nothing", w.name)
+ }
+ }
+}
+
+// TestStatelessPublicationCoversHibernating: a hibernating stateless build
+// needs the coordinator to wake, so the publication check refuses it too.
+func TestStatelessPublicationCoversHibernating(t *testing.T) {
+ fx, _ := copiesWorld(t)
+ placementEdit(t, fx, "a.example.com", func(r *provision.Record) { r.FleetBox, r.FleetBoxAt = "", "" })
+ ctx := withWriteMemo(t.Context())
+ m := &release.Manifest{App: "shop", Version: "h1", Kind: release.KindRootfs, Stateless: true, Hibernate: true}
+ ref := fx.srv.unlabelledFleetRefusal(ctx, fx.sqid, "shop")
+ if ref == nil || ref.Msg != fmt.Sprintf(copiesUnlabelled, "a.example.com", "pi") {
+ t.Fatalf("unlabelled guard: %+v", ref)
+ }
+ if got := fx.srv.statelessPublicationRefusal(ctx, fx.sqid, "shop", "edge", m, nil, ""); got == nil || got.Status != http.StatusConflict {
+ t.Fatalf("hibernating stateless publication: %+v", got)
}
}
diff --git a/internal/console/fleets.go b/internal/console/fleets.go
index 06f861fbc..4257d039d 100644
--- a/internal/console/fleets.go
+++ b/internal/console/fleets.go
@@ -414,6 +414,13 @@ func (s *Server) handleAPIFleetAddBox(w http.ResponseWriter, r *http.Request) {
"invalid box label — 1-32 characters of a-z, 0-9 and hyphen")
return
}
+ // #1008: a second active box would cut off an unlabelled instance that
+ // runs a stateless build on a one-box fleet (the coordinator's sole-box
+ // rule). AddFleetBox both adds and reactivates, so this covers both.
+ if ref := s.fleetGrowthRefusal(r.Context(), reg, acct, fleet.Name, label); ref != nil {
+ writeDoorRefusalJSON(w, r, ref)
+ return
+ }
plaintext, hash, err := mintFleetToken()
if err != nil {
log.Printf("console: fleet add-box %s/%s: mint token: %v", acct.Sqid, fleet.Name, err)
diff --git a/internal/console/rootfs.go b/internal/console/rootfs.go
index 0752ad035..e0e4a7dae 100644
--- a/internal/console/rootfs.go
+++ b/internal/console/rootfs.go
@@ -79,7 +79,7 @@ func (s *Server) statelessVersionRefusal(ctx context.Context, acct, app, channel
if err != nil {
return nil
}
- return s.statelessRuntimeRefusal(ctx, channel, m, nil, "")
+ return s.statelessPublicationRefusal(ctx, acct, app, channel, m, nil, "")
}
type statelessSelectionError struct{ ref *doorRefusal }
diff --git a/internal/console/server.go b/internal/console/server.go
index 98e73d774..d56ffc903 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -5876,7 +5876,7 @@ func (s *Server) handlePromote(w http.ResponseWriter, r *http.Request) {
back("err", ref.Msg)
return
}
- if ref := s.statelessRuntimeRefusal(ctx, channel, man, nil, ""); ref != nil {
+ if ref := s.statelessPublicationRefusal(ctx, acct.Sqid, app, channel, man, nil, ""); ref != nil {
back("err", ref.Msg)
return
}
@@ -6610,7 +6610,7 @@ func (s *Server) handleNewCanary(w http.ResponseWriter, r *http.Request) {
back("err", ref.Msg)
return
}
- if ref := s.statelessRuntimeRefusal(ctx, channel, man, nil, ""); ref != nil {
+ if ref := s.statelessPublicationRefusal(ctx, acct.Sqid, app, channel, man, nil, ""); ref != nil {
back("err", ref.Msg)
return
}