~ knotless Search/
↑↓ move↵ open⇧↵ all results

socialweb.computer/socialweb-computer-kcp

socialweb.computer: a compute market on atproto (kcp)

1 collaborator
0
0

runtime: start an APIExport provider only at the schemas this binary carries

Merged johnandersen777.bsky.social asked to merge into main from socialweb.computer/socialweb-computer-kcp:phase-2
docs/plans/0040-findings.md+44−0
@@ -1974,3 +1974,47 @@ Each: what was seen (with the log), the cause, the fix, its proof.
PROOF: `go build ./... && go vet ./internal/market/requester/`, `deploy/check.sh --fast` (exit 0), `cargo check -p
swc-test-host`, `cargo wasm`, `bash -n scripts/ci-test.sh`, `node --check capture.mjs`. Unproven without a CI cycle:
every retry path (needs a lost session or a PDS 5xx), the journal fetch on a real failure.
- PROMOTE 8 (rc184, main dbacebf6): cancelled by the owner's choice at 00:22Z 11-19 (its test-4 had failed at
stand-up: a put lost its iroh session, no entry ran). 22 prod entries had passed, none failed, 0014:impossible
among them. FIRST STOP JOB AFTER A CANCEL IN CI: `release-rollback` put prod back on rc180 (heartbeats, droplets
back, the promote's processes gone, exit 0) in 15 min; artifacts kept (130 of gate-runs).
- PROMOTE 9 (rc185, main a5269317, 01:18Z to 02:20Z): `gate: prod: 28 of 30 PASS`; artifacts kept (147 of
gate-runs: the release-workload output fix, composition bafyreicfmstnw2...). FAIL: 0006:run (bob) and 0008:run
(john), both on swc-dev-bidder-1 after the rc's self-update restart (01:19:43Z): one startup ERROR line, "Failed
to watch" of its ComputeVM informer against its own kcp at 01:19:46Z, healthy from 01:19:51Z, 0 restarts. Agent
`rc-watch`. Red: rolled back to rc180. Staging at a5269317: test-2 3/3, test-3 16/16, test-4 13/13 green; test-1:
status `error`, its CI machine never served its shell: THE BIDDER'S SELF-UPDATE (the same rc185 roll, 01:19:43Z)
STOPPED SERVING THE BINARY THE GUEST WAS STILL FETCHING (589 MB, sha of the old build; 404 for ever after the
restart; evidence ~/.tmp/rc-noshell/); rerun on the same commit at 01:32Z. Fix on branch `rc-pins` (reviewed:
safe, extended to the guest-downloads tree; `spec.guestDownloads`, ComputeVM schema revision 22; entry
0007:upgrade built, needs two landings; unproven until a hand run). Also ready, reviewed: `ten` (accept and RBAC
write retries); `rc-writes` 0fbbfded (webrtc ingress offer: CreateRecordAt, capped retry, fallback) awaits review.
- STARTUP "Failed to watch" ON A SCHEMA-CHANGING ROLL (promote a52693170d88, rc185, 2026-11-19: `gate: prod: 28 of 30
PASS`; 0006:run and 0008:run FAIL on swc-dev-bidder-1, `startupErrors: 1`). SEEN (bidder-1 journal, new pid 365479):
`01:19:46.339 ERROR "Failed to watch" logger controller-runtime/cache/UnhandledError err: Get
"https://127.0.0.1:35243/clusters/%2A/apis/socialweb.computer/v1alpha1/computevms:975fd017...?allowWatchBookmarks=true&resourceVersion=37557&timeoutSeconds=350&watch=true":
context canceled`, type *v1alpha1.ComputeVM. kcp (adopted, never restarted) logged at 46.338762 `apiserver received an
error that is not an metav1.Status: url.Error{Get .../computevms:975fd017... context canceled}`: the error came back
from kcp's APIExport virtual workspace, which proxies the wildcard watch to the shard. Sequence (bidder-1, all 01:19):
43 unit start; 45.925 kcp-a adopted; 45.968 component controller applies the workspaces; 46.024 controller manager
starts; 46.207 provider `computevms` starts (awaitKinds passed at once); 46.263/46.280 the `applications` and
`provider` sets' schemas phases apply the APIExport `computevms` naming `v1alpha1-21.computevms` (it named `-20`);
46.282 kcp creates the new bound CRDs (root|computevms, bvkdm0s87fja46y0|computevms-cobha); 46.286 the VW creates the
API definition of the new schema; 46.338 it swaps the API set and tears the `-20` definition down, cancelling the
provider's open watch (resourceVersion 37557: it had listed and was watching). CAUSE: the controller manager starts an
APIExport provider as soon as the export lists the provider's GroupKinds (`awaitKinds`) and its bindings list the
GroupResources (`awaitBound`); the export from before the roll satisfies both, so the provider watches the old schema's
VW definition and the core's own schema apply 60 ms later replaces it under the watch. Every roll between rc180
(7a0406d9, before a09c3c1d) and a later rc changes the ComputeVM schema (`-20` <-> `-21`): on bidder-1 every restart
since 2026-11-18 20:16 (10, forward and rollback) logs "creating CRD" and "creating API definition" for computevms.
Whether a watch is open at the swap is timing: bidder-2 (provider 46.343, swap 46.436) and bidder-3 (46.231, swap
46.356) raced the same way and logged nothing; 1 hit in about 30 restarts of swc-dev-bidder-1..3 since 20:16 (none on 2 and 3). Hosting VMs
is not the cause (only the timing). FIX (`internal/controllers/runtime/exportkinds.go`, `manifests/exports.go`): a
GroupKind counts as served only at a schema this binary carries (the embedded `deploy/*-apiexport.yaml`,
`manifests.ExportSchemas`), and a binding counts as bound only when each resource is bound at the export's schema
name (`boundResources[].schema.name`); so a provider whose export or binding still names another schema waits (the
existing watch-driven AwaitList, ExportKindsTimeout 1 min, then the existing Warn) for the core's own schema apply
and kcp's rebind before it starts. PROOF: `go build ./... && go vet ./internal/controllers/runtime/...`,
`deploy/check.sh --fast`. Unproven: a schema-changing roll with the fix (the next promote that rolls from rc180 is
one); the window left between the binding status write (46.292 to 46.315 on bidder-1) and the VW swap (46.338) is
about 25 ms, shorter than a provider's start to its first open watch, but nothing orders the two.
docs/plans/0040-release-pipeline.md+16−10
@@ -3,16 +3,17 @@
Status: the only plan in flight (owner, 2026-11-17); docs/plans/0001-0039 and NEXT.yaml are history. How to run, hold
and debug CI by hand: `docs/ci-debug.md`. The state before this work: main e39097c2 (2026-11-12).
State (2026-11-18 23:40Z; updated by the lead):
- Main is dbacebf6: everything of this plan. Since a4aa6d62: `promote.sh prepare` gives the gate user what staging's
has (ee133538); staging fetches failed gate runs and 0014 judges a refusal by its round (dbacebf6).
- STAGING IN CI: 43 of 43 PASS on main d6a2b391 (17:08Z; `scripts/ci-staging-total.sh`). a4aa6d62: 42 of 43
(0014:concurrent, once; cause unproven, findings). ee133538: test-2, test-3, test-4 green, test-1 running.
- PROD IN CI: 29 of 30 PASS at ee133538 (promote rc183, 23:33Z). FAIL: 0014:impossible (bob: his own compute.vm
record write failed). Before it 26 of 30 at a4aa6d62. Red, rolled back: prod runs rc180 (main 7a0406d9).
- Rolls: 0 of 2. Seven promotes, each red for a different cause, each fixed or in work (findings). Promote 8 (rc184,
dbacebf6) running since 23:34Z. Owner's target: roll one green by 01:30Z 11-19.
State (2026-11-19 02:25Z; updated by the lead):
- Main is a5269317: everything of this plan plus retries of one-off network failures (requester setup and RFP
writes, staging stand-up puts and ssh steps) and failure evidence (whole notes, journals, the watch capture).
- STAGING IN CI: 43 of 43 PASS on main d6a2b391 (17:08Z 11-18; `scripts/ci-staging-total.sh`). a5269317: test-2,
test-3, test-4 green; test-1 rerun running (its first machine was lost to the rc's bidder self-update: findings).
- PROD IN CI: 29 of 30 at ee133538 (rc183); 28 of 30 at a5269317 (rc185, 02:20Z): 0006:run and 0008:run, one
bidder's startup ERROR line after the roll's restart (agent `rc-watch`). Red, rolled back: prod runs rc180.
- Rolls: 0 of 2. Nine promotes (one cancelled), each red for a different cause, each fixed or in work (findings).
The owner's target of 01:30Z 11-19 for roll one is missed.
- Open product fix, not landed: a bidder's self-update drops the downloads its live guests still fetch (`rc-pins`).
- Compute: three `swc-dev` droplets (c-32, $1/h each), bob's bidders; destroy when the plan is done. After any CI
cancel: remove the VMs it leaves on the bidders (`~/.tmp/int/rm-orphans.sh`) until prod runs the association fix.
@@ -466,6 +467,11 @@ All answered 2026-11-17.
already what you are doing". Done when 2 is CI's promote, 30 of 30. Target for today: roll one green by 5:30 PM
Pacific (01:30Z 11-19): "if the roll one lands by 5:30 then I'll be happy".
39. (2026-11-18, AskUserQuestion) No rotation of the seven CI secrets whose sealed copies sat on knotless.dev. The prod gate gets more drivers: "You can add john and socialweb.computer". The two-grants question of the orphan-VM fix: "Decide later" (plan 0041).
40. (2026-11-18, AskUserQuestion) Promote 8 (its test-4 had failed at stand-up): "Cancel it now".
41. (2026-11-19, AskUserQuestion) The bidder's one startup ERROR line after a roll (its own schema apply cancels a
watch opened on the old definition; 0006:run and 0008:run require zero): "Gate only for now": the provider waits
for the schemas its binary carries; what is logged does not change and neither does the assertion; revisit with
evidence if the line recurs.
internal/controllers/runtime/manifests/exports.gonew+51−0
@@ -0,0 +1,51 @@
package manifests
import (
"fmt"
"io/fs"
"sync"
apisv1alpha2 "github.com/kcp-dev/sdk/apis/apis/v1alpha2"
"github.com/johnandersen777/socialweb-computer-kcp/deploy"
)
const exportGlob = "*-apiexport.yaml"
var exportSchemas = sync.OnceValues(func() (map[string]map[string]bool, error) {
paths, err := fs.Glob(deploy.FS, exportGlob)
if err != nil {
return nil, fmt.Errorf("manifests: %s: %w", exportGlob, err)
}
out := map[string]map[string]bool{}
for _, path := range paths {
body, err := fs.ReadFile(deploy.FS, path)
if err != nil {
return nil, fmt.Errorf("manifests: %w", err)
}
objs, err := Decode(path, body)
if err != nil {
return nil, err
}
for _, o := range objs {
e, ok := o.Typed.(*apisv1alpha2.APIExport)
if !ok {
continue
}
schemas := map[string]bool{}
for _, r := range e.Spec.Resources {
schemas[r.Schema] = true
}
out[e.Name] = schemas
}
}
return out, nil
})
func ExportSchemas(export string) (map[string]bool, error) {
all, err := exportSchemas()
if err != nil {
return nil, err
}
return all[export], nil
}
internal/controllers/runtime/exportkinds.go+12−4
@@ -19,6 +19,7 @@ import (
"github.com/johnandersen777/socialweb-computer-kcp/api/kcpgvr"
"github.com/johnandersen777/socialweb-computer-kcp/internal/controllers/runtime/kube"
"github.com/johnandersen777/socialweb-computer-kcp/internal/controllers/runtime/manifests"
)
const (
@@ -52,6 +53,10 @@ func (m *Manager) awaitKinds(ctx context.Context, export string) {
m.log.Warn("the APIExport provider does not wait for its kinds", "export", export, "err", err.Error())
return
}
carried, err := manifests.ExportSchemas(export)
if err != nil {
m.log.Warn("the APIExport provider does not know the schemas it carries", "export", export, "err", err.Error())
}
schemas := c.Resource(kcpgvr.APIResourceSchemas)
known := map[string]schema.GroupKind{}
var resources []apisv1alpha2.ResourceSchema
@@ -63,6 +68,9 @@ func (m *Manager) awaitKinds(ctx context.Context, export string) {
if i >= 0 {
resources = items[i].Spec.Resources
for _, r := range resources {
if len(carried) > 0 && !carried[r.Schema] {
continue
}
gk, ok := known[r.Schema]
if !ok {
s, err := kube.Get[apisv1alpha1.APIResourceSchema](ctx, schemas, r.Schema)
@@ -87,7 +95,7 @@ func (m *Manager) awaitKinds(ctx context.Context, export string) {
if !waiting {
waiting = true
slices.Sort(left)
m.log.Info("the APIExport provider waits for its kinds; the schema apply wakes it", "export", export, "kinds", left)
m.log.Info("the APIExport provider waits for its kinds at the schemas this binary carries; the schema apply wakes it", "export", export, "kinds", left)
}
return false, nil
})
@@ -115,12 +123,12 @@ func (m *Manager) awaitBound(ctx context.Context, ws, export string, resources [
if ref := b.Spec.Reference.Export; ref == nil || ref.Name != export {
continue
}
bound := map[schema.GroupResource]bool{}
bound := map[schema.GroupResource]string{}
for _, r := range b.Status.BoundResources {
bound[schema.GroupResource{Group: r.Group, Resource: r.Resource}] = true
bound[schema.GroupResource{Group: r.Group, Resource: r.Resource}] = r.Schema.Name
}
for _, r := range resources {
if !bound[schema.GroupResource{Group: r.Group, Resource: r.Name}] {
if bound[schema.GroupResource{Group: r.Group, Resource: r.Name}] != r.Schema {
return false, nil
}
}
.plans.yaml+1−1
@@ -15,7 +15,7 @@ plans:
waits_on: "steps 6-10"
prod_ci:
target: "CI promote 30 of 30 both-entries PASS as prod bob and alice, on step 21's second roll"
now: "29 of 30 PASS in CI at main ee133538 (promote rc183, 23:33Z 11-18; FAIL 0014:impossible as bob: his compute.vm record write failed: agent rc-0014i; before it 26 of 30 at a4aa6d62); promote 8 (rc184, dbacebf6) running; log: knotless run list --commit ee133538 --workflow promote --log"
now: "28 of 30 PASS in CI at main a5269317 (promote rc185, 02:20Z 11-19; FAIL 0006:run, 0008:run: one startup ERROR line on swc-dev-bidder-1 after the roll restart: agent rc-watch; best so far 29 of 30 at ee133538); log: knotless run list --commit a52693170d88 --workflow promote --log"
log: "none yet"
waits_on: "steps 0-20"
ci_rolls: