console: D1 refuses an unreadable release before C08 (M2 rereview B)
On a D1-eligible create (fleetCreateApplies on the record's kind and addresses), a selected release that cannot be read is C39 (503, Retry-After 30) before the rootfs history fallback, which answered C08 (502) for a manifest that stays unreadable. Other creates are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+15
−1
internal/console/apiinstances.go+11 −0internal/console/apiinstances_test.go+4 −1
Intent
Attributed to this commit: 10.1 g CO₂e (1,301,051 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on fleet-record-labels-m2, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go| index bbe145a0e..61ddf6b63 100644 |
| --- a/internal/console/apiinstances.go |
| +++ b/internal/console/apiinstances.go |
| @@ -2192,6 +2192,17 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request) |
| fleetActive = &v |
| } |
| } |
| + // A D1-eligible create (fleetCreateApplies on the record's kind and |
| + // addresses) whose selected release could not be read is C39 here, |
| + // before the history fallback below would answer C08 for a manifest |
| + // that stays unreadable (M2 re-review B). Other creates are unchanged. |
| + if chHeadErr != nil && fleetName != "" && |
| + s.fleetCreateApplies(fleetSeen, fleetErr, provision.Record{Kind: strings.TrimSpace(req.Kind), Addrs: req.Addrs}) { |
| + log.Printf("console: api instances create %s/%s/%s: fleet %s: selected release cannot be read (%v); refused", acct.Sqid, app, host, fleetName, chHeadErr) |
| + w.Header().Set("Retry-After", fleetCreateRetryAfter) |
| + jsonError(w, http.StatusServiceUnavailable, msgFleetCreateUnavailable(fleetName)) |
| + return |
| + } |
| // Rootfs apps (rootfs spec §5.0, §5.6, §5.7; Plan 4 Task 3). Only a |
| // socket-backed instance is a process the platform starts, so only its |
| // create asks what the creating release is: a static or addr-backed |
diff --git a/internal/console/apiinstances_test.go b/internal/console/apiinstances_test.go| index 164826c1f..248075b81 100644 |
| --- a/internal/console/apiinstances_test.go |
| +++ b/internal/console/apiinstances_test.go |
| @@ -3405,9 +3405,12 @@ func TestCreateRefusesAnUnreadableSelectedRelease(t *testing.T) { |
| }{ |
| {"pointer", func(sqid string) string { return release.ChannelKey(sqid, "shop", "edge") }, -1}, |
| {"manifest", func(sqid string) string { return release.ManifestKey(sqid, "shop", "v1") }, 1}, |
| + // M2 re-review B: a manifest that is never readable is C39 too, not |
| + // the history fallback's C08 (502, no Retry-After). |
| + {"manifest never readable", func(sqid string) string { return release.ManifestKey(sqid, "shop", "v1") }, -1}, |
| } { |
| t.Run(c.name, func(t *testing.T) { |
| - fx, token, reg := d1World(t, "code-d1-unread-"+c.name, "pi-1", "pi-2") |
| + fx, token, reg := d1World(t, "code-d1-unread-"+strings.ReplaceAll(c.name, " ", "-"), "pi-1", "pi-2") |
| shipVersion(t, fx, "shop", "v1") |
| seedChannel(t, fx, "shop", "edge", "v1") |
| fx.forgetFrame("shop") |