0
0
bidder: reload a guest's nftables rules when it adopts it (plan 0040 decision 75); entry 0007:fence
.knotless/workflows/test.yml+1−1
| @@ -2,7 +2,7 @@ | ||
# requester R2). It stands up ONE staging network (tests/compositions/staging, the multi-VM layout: an atproto VM, two 4/8 nested-virt bidder VMs and a gateway | ||
# VM on one meshd overlay, rented by R2) on THIS commit's build and runs every entry of tests/entries.txt on it (tests/gate.sh from the network's atproto VM as | ||
# its alice1..alice4, four at once; scripts/ci-test.sh input_default); an exclusive entry (gate.sh GATE_EXCLUSIVE: 0001, 0007:restart, 0007:upgrade, | ||
# 0014:*, 0014:memfit among them) is alone on it. The step prints its RESULT lines and `gate: staging: N of 46 PASS` (`scripts/ci-staging-total.sh <commit>` reads it back). | ||
# 0014:*, 0014:memfit among them) is alone on it. The step prints its RESULT lines and `gate: staging: N of 47 PASS` (`scripts/ci-staging-total.sh <commit>` reads it back). | ||
# `promote` runs after this one (owner, 2026-11-19: staging and prod in series, for less compute). The socialweb-computer is release's linux/amd64 of this commit (main: the bucket's | ||
# main/<sha>/; a branch: pulled by digest from ttl.sh, its artifact oci/binary.ref) on the CI VM and on every staging VM; the test host and meshd are release's | ||
# too (the bucket on main, its artifacts dist/ on a branch). Nothing here builds. Runs after `release` on a push to main that changes code (paths below; the | ||
cmd/socialweb-computer/bidder.go+3−2
| @@ -763,8 +763,9 @@ func (r *bidderRun) installedCore(ctx context.Context) int { | ||
if err != nil { | ||
return r.a.fail(exitRefused, "%s: %v", verb, err) | ||
} | ||
guestNetwork := spec.GuestNetwork.EffectiveFor(spec.Policy) | ||
vm := devinstance.VMRuntime{Handle: r.handle, Backend: hostsvc.BackendSystemdUser, ImageSource: r.vals.String("guest-image-source"), | ||
StopGrace: grace.String(), RuntimeDir: runtimeDir, VMM: vmm, Executables: paths} | ||
StopGrace: grace.String(), RuntimeDir: runtimeDir, VMM: vmm, Executables: paths, GuestNetwork: &guestNetwork} | ||
m, err := hostsvc.Open(ctx, hostsvc.Config{Backend: hostsvc.BackendSystemdUser, UnitPrefix: prefix}) | ||
if err != nil { | ||
return r.a.fail(exitFailed, "%s: the systemd-user backend: %v", verb, err) | ||
| @@ -783,7 +784,7 @@ func (r *bidderRun) installedCore(ctx context.Context) int { | ||
} | ||
unit, _ := r.a.env.LookupEnv(devsup.EnvUnit) | ||
cfg := bidder.CoreConfig{StateDir: state, Prefix: prefix, Handle: r.handle, Executables: exes, Spec: spec, VM: vm, | ||
ComputeVM: computevm.Config{Handle: r.handle, Runtime: rt, Manager: m, Log: r.a.log}, FrontAddress: r.vals.String("kcp-front-address"), | ||
ComputeVM: computevm.Config{Handle: r.handle, Runtime: rt, Manager: m, GuestNetwork: vm.GuestNetwork, Log: r.a.log}, FrontAddress: r.vals.String("kcp-front-address"), | ||
ReadyTimeout: r.readyTimeout, Unit: unit, Log: r.a.log, OpsReadSecretFile: r.vals.String("ops-read-secret-file")} | ||
if err := bidder.RunCore(ctx, cfg, m); err != nil { | ||
if errors.Is(err, context.Canceled) { | ||
cmd/socialweb-computer/dev.go+1−1
| @@ -1088,7 +1088,7 @@ func runDevCore(ctx context.Context, a *app, vals clicfg.Values, rest []string) | ||
return a.fail(exitFailed, "internal dev-core: the instance is a bidder application instance (handle %s) and its VM runtime does not open: %v", rec.VM.Handle, err) | ||
} | ||
defer vm.Close() | ||
cfg.ComputeVM = &computevm.Config{Handle: rec.VM.Handle, Runtime: rt, Manager: vm, Log: a.log} | ||
cfg.ComputeVM = &computevm.Config{Handle: rec.VM.Handle, Runtime: rt, Manager: vm, GuestNetwork: rec.VM.GuestNetwork, Log: a.log} | ||
} | ||
if err := devcore.Run(ctx, cfg, m); err != nil { | ||
if errors.Is(err, context.Canceled) { | ||
deploy/swc-userns-stage/stage.c+70−1
| @@ -10,9 +10,43 @@ | ||
#define SYS_unshare 272 | ||
#define SYS_pipe2 293 | ||
#define SYS_exit_group 231 | ||
#define SYS_socket 41 | ||
#define SYS_sendmsg 46 | ||
#define SYS_setns 308 | ||
#define CLONE_NEWUSER 0x10000000 | ||
#define CLONE_NEWNET 0x40000000 | ||
#define SIGCHLD 17 | ||
#define O_CLOEXEC 02000000 | ||
#define AF_NETLINK 16 | ||
#define SOCK_RAW 3 | ||
#define NETLINK_NETFILTER 12 | ||
#define SOL_SOCKET 1 | ||
#define SCM_RIGHTS 1 | ||
#define JOIN_PIDFD 3 | ||
#define JOIN_SOCK 4 | ||
| ||
struct iovec_ { | ||
void *base; | ||
unsigned long len; | ||
}; | ||
| ||
struct msghdr_ { | ||
void *name; | ||
unsigned long namelen; | ||
struct iovec_ *iov; | ||
unsigned long iovlen; | ||
void *control; | ||
unsigned long controllen; | ||
unsigned long flags; | ||
}; | ||
| ||
struct cmsg_fd { | ||
unsigned long len; | ||
int level; | ||
int type; | ||
int fd; | ||
int pad; | ||
}; | ||
| ||
static long sys6(long n, long a, long b, long c, long d, long e, long f) { | ||
long ret; | ||
| @@ -99,12 +133,47 @@ static __attribute__((noreturn)) void helper(int rfd, char *ppid, char *uidb, ch | ||
__builtin_unreachable(); | ||
} | ||
| ||
static int is_join(const char *s) { | ||
return s[0] == 'j' && s[1] == 'o' && s[2] == 'i' && s[3] == 'n' && s[4] == 0; | ||
} | ||
| ||
static __attribute__((noreturn)) void join(void) { | ||
long r = sys3(SYS_setns, JOIN_PIDFD, CLONE_NEWUSER | CLONE_NEWNET, 0); | ||
if (r < 0) die("setns(pidfd 3, CLONE_NEWUSER|CLONE_NEWNET)", r); | ||
long s = sys3(SYS_socket, AF_NETLINK, SOCK_RAW | O_CLOEXEC, NETLINK_NETFILTER); | ||
if (s < 0) die("socket(AF_NETLINK, NETLINK_NETFILTER)", s); | ||
char one = 'x'; | ||
struct iovec_ v; | ||
v.base = &one; | ||
v.len = 1; | ||
struct cmsg_fd c; | ||
c.len = 20; | ||
c.level = SOL_SOCKET; | ||
c.type = SCM_RIGHTS; | ||
c.fd = (int)s; | ||
c.pad = 0; | ||
struct msghdr_ m; | ||
m.name = 0; | ||
m.namelen = 0; | ||
m.iov = &v; | ||
m.iovlen = 1; | ||
m.control = &c; | ||
m.controllen = sizeof c; | ||
m.flags = 0; | ||
r = sys3(SYS_sendmsg, JOIN_SOCK, &m, 0); | ||
if (r != 1) die("sendmsg(fd 4, SCM_RIGHTS)", r); | ||
sys3(SYS_exit_group, 0, 0, 0); | ||
__builtin_unreachable(); | ||
} | ||
| ||
__attribute__((used)) void stage_main(long *sp) { | ||
long argc = sp[0]; | ||
char **argv = (char **)(sp + 1); | ||
char **envp = argv + argc + 1; | ||
if (argc == 2 && is_join(argv[1])) join(); | ||
if (argc < 6) { | ||
say("usage: swc-userns-stage <outer-uid> <outer-gid> <count> <inner-id> <program> [args...]\n"); | ||
say("usage: swc-userns-stage <outer-uid> <outer-gid> <count> <inner-id> <program> [args...]\n" | ||
" swc-userns-stage join (fd 3: a pidfd; fd 4: a unix socket that gets a NETLINK_NETFILTER socket of that process's user and network namespaces)\n"); | ||
sys3(SYS_exit_group, 2, 0, 0); | ||
} | ||
long count = atou(argv[3]); | ||
docs/acceptance/0007-bidder-termination.md+39−0
| @@ -146,6 +146,45 @@ stops after 30 s when its rate would not finish inside 20 min; then it runs | ||
it differs from that pin, from a kept older downloads tree (a path not under `bin/`); reading `agentFrom` | ||
- the release leaves no record; every bidder is back on the binary under test, ready, 0 automatic restarts, 0 startup ERROR | ||
| ||
## A guest's rules follow its bidder through an upgrade (`0007:fence`, staging) | ||
| ||
A guest's nftables bridge table `swcguest` is loaded by vmexec when the VM boots; a bidder core that adopts a running | ||
guest (a self-update, a rollback, a restart) replaces it with its own rule set in one nf_tables transaction (plan 0040 | ||
decision 75; AGENTS.md "A guest's rules follow the running bidder"). The promote it fixes: its requester ran in a guest | ||
booted by the previous rc, which had no decision 54 rule, so WebRTC to a guest of the same host (guest tap to the | ||
host's own address on the target's forwarded port, 31000-31999) was dropped (docs/plans/0040-findings.md, "PROMOTE | ||
93fd8c11 ROOT CAUSE"). | ||
| ||
Test: `tests/compositions/0007` entry `fence`; staging only (it upgrades a bidder under a running guest), exclusive. The | ||
from binary is `SWC_UPGRADE_FROM`, else `SWC_COMPAT_REQUESTER`; it must be one without decision 54's rule (688c2105 or | ||
older), else the entry ends `unmet`. Host calls: `bidder.upgrade` (above), `bidder.guestNft {name, vm, owner, op}` (as | ||
root on the bidder VM, `nsenter -n nft` in the VMM's network namespace: `list` the product table; `probe` a test-only | ||
table `bridge swcprobe` of two counters with no verdict for UDP from the guest's tap to the host's own IPv4 addresses on | ||
31000-31999, chain `sent` at priority -301 before `swcguest` and chain `passed` at -299 after it; `counters`; `unprobe`), | ||
`bidder.awaitLog {name, texts, seconds}` (the bidder's journal followed until a line holds every text) and | ||
`binary.published` (the bucket URL of the binary under test: main/ or local/ of the commit its `version` names). Steps | ||
and asserts, all on the target's first bidder B: | ||
| ||
- B is upgraded to the from binary; G (`--hold --guest-tools socialweb-computer --associate guest`, allow-bidder-dids | ||
B) is Held on B; G's `swcguest` holds no accept of 31000-31999 (else `unmet`) | ||
- the probe is loaded; G fetches the binary under test (its guest tools are the from binary, which cannot pin a bidder; | ||
the promote's requester also ran the binary under test in a guest of the previous rc) | ||
- G's guest requester (user r2, `--guest-requester --skip-ssh=false`: one invocation, a guest's association serves one) | ||
holds T pinned to B with `--tunnel ssh:22:webrtc`; G's ssh session `cat` of a fifo opens (it must stay open to the end) | ||
- from inside G, `run request ssh T --transport webrtc --exec -- uname -a`: it fails (ICE: no candidate pair); `sent` > | ||
0 and `passed` 0 (G's packets to B's own address on T's forwarded port dropped by `swcguest`) | ||
- B is upgraded to the binary under test with G running; B's journal shows `guest_rules_reloaded` for G's | ||
FirecrackerVM with `webrtcUDPPorts` `31000-31999`; G's `swcguest` now holds that accept | ||
- the same ssh from inside G exits 0 with `uname -a`; `passed` > 0 (decision 54's rule matched, packet by packet) | ||
- B is rolled back to the from binary: G's `swcguest` is unchanged (that binary reloads nothing); B is upgraded again: | ||
`guest_rules_reloaded` again and the table is byte for byte the one of the first reload | ||
- the fifo is written: G's ssh session opened before the first upgrade ends cleanly with what was written | ||
- the probe goes, T and G are released, B runs the binary under test | ||
| ||
The guest requester's own atirc token mint answers 403 "association not verified" for minutes right after the grant | ||
(0005's note; the requester retries it, the rental does not wait on it): the entry counts those lines | ||
(`readings.atirc_mint_403`) instead of failing fast on them. | ||
| ||
## Preconditions | ||
| ||
- Authority: the owner asked for it, or the VM is matched to a contract you are ending (stray test / orphan). Never an owner-held VM unless the owner says so | ||
docs/plans/0040-findings.md+38−0
| @@ -3311,3 +3311,41 @@ Each: what was seen (with the log), the cause, the fix, its proof. | ||
its firewalld zone opened no UDP (decision 76, opened 31000-31999/udp); it hosted no gate VM this time (declined | ||
for capacity). LESSON: a rule or guest-side change shipped in a release is not on guests booted before the roll; | ||
the hand prod proof must run from inside a guest rented on a prod bidder, on the same host as its target. | ||
- FENCE ON ADOPT (decision 75; branch `fence-on-adopt`, evidence `~/.tmp/fence-adopt/proof/`). FIX: the first Running | ||
reconcile of each FirecrackerVM in a core process reloads that guest's table `swcguest` from the core's own rule set | ||
(a VM the core booted itself is skipped; once per VM invocation per process), in ONE nf_tables transaction (add table, | ||
delete table, add table + chains + rules). Boot and reload share the wiring (`vmruntime.planFor`) and the rule builder | ||
(`guestnet.fenceMessages`); the bidder-level lanUDP, hostUDP and webrtcUDPPorts come from the running bidder's | ||
`EffectiveFor` (`computevm.Config.GuestNetwork`), the VM's hostPorts, webrtcUDPPort and networkTCP from its spec. | ||
DIFFERENCE FOUND between boot's spec and adopt: a ComputeVM written by 688c2105 has no `webrtcUDPPorts` (its binary | ||
had no such field), so reloading from the spec alone would load no decision 54 rule; the bidder's own range is used | ||
instead (nothing else differs; boot's semantics kept: a guest the new core boots gets the same values). REACH, no new | ||
privilege: `swc-userns-stage` unshares each VM's user namespace as the bidder uid, so the bidder owns it and (the | ||
kernel's owner rule) holds every capability in it and in pasta's child user namespace that owns the guest netns; Go | ||
cannot setns(CLONE_NEWUSER), so the bidder runs its own release's stub as `swc-userns-stage join` (fd 3 a pidfd of the | ||
recorded VMM pid, pinned after the unit identity check and compared to the recorded start ticks; fd 4 a socketpair): | ||
setns(3, CLONE_NEWUSER|CLONE_NEWNET), one NETLINK_NETFILTER socket back over SCM_RIGHTS, exit; the bidder sends the | ||
batch itself. Prototyped first on hat-8 as an unprivileged user with a real stage+pasta namespace. Logged | ||
`guest_rules_reloaded` (the wiring) or `guest_rules_reload_failed` (the reconcile retries with its backoff). The prod | ||
bidder on hat-8 runs `unconfined_t`, the domain the prototype ran in. TESTCASE: staging entry `0007:fence` | ||
(exclusive; acceptance 0007 section "A guest's rules follow its bidder through an upgrade"); host calls | ||
`bidder.guestNft`, `bidder.awaitLog`, `binary.published`. PROOF on held network stg-989592 (branch build 56b6098d | ||
published under local/ only; from = 688c2105): (1) the cleanup of a frozen run upgraded bob2 under a 688c2105-booted | ||
guest: `guest_rules_reloaded` for fc-ps63mutz5r7n-9026c5a6 and its table gained the accept | ||
(`run1-cleanup-reload.txt`). (2) `0007:fence` PASS 719.8 s as alice2 (`run3-*`): 688c2105's table held no range accept; | ||
from inside G, ssh over WebRTC to T on the same bidder failed "ICE failed ... no ICE candidate pair connected" (the red | ||
promote, reproduced) with probe sent 16 passed 0; upgrade, reload logged 8.6 s after (webrtcUDPPorts 31000-31999); | ||
the only diff of the table is one line, `iifname "fctap0" ip daddr 10.44.0.2 udp dport 31000-31999 udp dport != 1900 | ||
udp dport != 5353 udp dport != 5355 accept` (`run3-swcguest-before.nft`, `run3-swcguest-after.nft`); the same ssh | ||
then printed `uname -a` (exit 0), probe sent 56 passed 40 (decision 54's rule, packet by packet: first proof); | ||
rollback to 688c2105: table unchanged (`run3-swcguest-after-rollback.nft`); second upgrade: reloaded, byte-identical; | ||
G's iroh ssh session opened before the first upgrade stayed open 82 s and ended cleanly. (3) `0007:fence` PASS again, | ||
528.6 s as alice3 (`run4-*`): the same one-line diff, ICE failed before, `uname -a` after, probe 16/0 then 54/38, | ||
reload 11.2 s after the upgrade, rollback unchanged, second reload identical, the session open 84 s. (4) FAMILIES. | ||
ROLLBACK: a binary with this code re-applies its own older rule set; a binary before it (688c2105 and older) has no | ||
`join`, reloads nothing, and its adopted guests keep the newer rules until they end (shown above). SIDE FINDING (not | ||
this fix): a non-agent guest requester's own atirc token mint answers 403 "association not verified" for minutes | ||
after the grant (0005's rc165 note; 0005 avoids it with `--agent`); 0007:fence run 2 as alice1 failed fast on it | ||
(11 times in 299 s); the entry now counts it (`readings.atirc_mint_403`). NOT PROVEN: prod hosts (no prod bidder runs | ||
this binary); SELinux enforcing on a prod hat for the stub's setns (same domain as the prototype, not run there); | ||
QEMU guests only (staging's bidders run `--vmm qemu`; firecracker shares the path: the pidfd is the recorded VMM's). | ||
docs/plans/0040-release-pipeline.md+16−6
| @@ -3,7 +3,7 @@ | ||
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-20 23:00Z; updated by the lead): | ||
State (2026-11-21 04:50Z; updated by the lead): | ||
| ||
- Main: CI in series on four home bidders (decision 43), the fixes of promote 11's cycle, the kcp docs, the site | ||
from the repo (`site/`), the protocol docs. | ||
| @@ -76,9 +76,11 @@ State (2026-11-20 23:00Z; updated by the lead): | ||
failed before the datachannel opened): all three WebRTC, all with the requester inside the release VM. Rolled | ||
back by the run itself: rc back on v0.0.0-rc186, every bidder heartbeats d4933943 again (read 22:59Z), stable | ||
not moved. | ||
- Now: root cause of the three from the promote's artifacts (`~/.tmp/promote-93fd/report.md`), the fix run out of | ||
band in promote's own topology (a requester inside a guest rented on a prod bidder), then the next cycle is roll | ||
one again; `cli-help` (decision 74) waits as roll two. | ||
- Root cause of the red promote: a guest's rules were loaded once by the bidder that booted it; promote's own | ||
VM never had decision 54's rule (Findings). Fix (decision 75): the bidder reloads an adopted guest's rules; | ||
entry 0007:fence reproduces promote's topology (staging 47). hat-10's zone opened for UDP 31000-31999 | ||
(decision 76). | ||
- Now: roll one again, on the pull of `fence-on-adopt` (decision 77); `cli-help` (decision 74) is roll two. | ||
- Relay (deployed by hand, not in the pipeline): 97bba4a7 then e7251bbc on xrpc.fedproxy.com; takeover refused on | ||
the live relay with throwaway identities; requests fell from about 290/s to under 1/s. | ||
- Landed without CI (docs, site): the site from `site/` with `/install.sh`, white pages, build-time highlighting, | ||
| @@ -183,7 +185,7 @@ DNS (`/etc/systemd/resolved.conf.d/public.conf`): the region's resolver answers | ||
| ||
## Entries | ||
| ||
`tests/entries.txt` (46; `tests/gate.sh` reads it): *staging* entries run on staging only (15); the rest run on both (31). 0010 (iOS) was | ||
`tests/entries.txt` (47; `tests/gate.sh` reads it): *staging* entries run on staging only (16); the rest run on both (31). 0010 (iOS) was | ||
removed (owner, 2026-11-17). | ||
| ||
| Entry | Proves | | ||
| @@ -202,6 +204,7 @@ removed (owner, 2026-11-17). | ||
| 0007:restart | *staging* (restarts a bidder's core): the bidder core restarted in place under a Held VM, its unit unchanged | | ||
| 0007:webrtc | getSecrets over the WebRTC channel (iroh off by the contract's user_data): log and contract say webrtc, files written, nothing left | | ||
| 0007:upgrade | *staging* (every bidder changes binary): a guest placed before its bidder's self-update still gets its binaries from the new core and is Held | | ||
| 0007:fence | *staging* (a bidder changes binary under a running guest): the new core reloads the guest's nftables rules (decision 75); from inside the guest, WebRTC to a guest of the same bidder fails before and works after; its open ssh survives | | ||
| 0008:run | a VM's timeline on its host, release, vm.terminated, records gone, orphan check on every host | | ||
| 0009:run | the browser page rents per bidder over webrtc, a shell over the datachannel, nothing left | | ||
| 0011:run | atirc deploy gates (binary, /chat, unauthenticated revoke 401) | | ||
| @@ -715,6 +718,13 @@ All answered 2026-11-17. | ||
76. (2026-11-20) hat-10's firewalld zone opened no UDP (hat-9: 31000-31999/udp; hat-7, hat-8: 1025-65535/udp); answer: | ||
"Yes, match hat-9": done by the lead 23:2xZ: `firewall-cmd --zone=FedoraServer --add-port=31000-31999/udp`, runtime | ||
and permanent (before: `1997/tcp`; after: `1997/tcp 31000-31999/udp`). | ||
77. (2026-11-21) The reload-on-adopt fix lands without a full hand staging cycle (owner: "should we just yeet it and | ||
see jowbit goes? its just the firewall rule apply on already exisiting vms right?"): CI's `test` runs all 47 | ||
entries before `promote` touches prod, so the hand cycle would repeat it. Kept: the fix's own proof on a held | ||
staging network (0007:fence four runs, the rule tables before, after and after rollback, probes 0 of 16 before | ||
and 40 of 40 after), a strict review of the rule swap (one nf_tables transaction, the old table kept on any | ||
failure, same rule function as boot, the VMM pinned by pidfd before setns, the adopting binary's own stub), and | ||
build plus `deploy/check.sh --fast`. This is for this fix only; decision 51 stands. | ||
| ||
| ||
| ||
| @@ -772,7 +782,7 @@ Owner questions open: | ||
Steps 0-15, 17 and 20 done (16, 18 and 19 moved to plan 0041: owner decision 33), then step 21; on the commit of | ||
step 21's second roll: | ||
| ||
1. staging: CI `test` 46 of 46 PASS, 0 FAIL on a push run: the step log's gate summary. | ||
1. staging: CI `test` 47 of 47 PASS, 0 FAIL on a push run: the step log's gate summary. | ||
2. prod: CI `promote` (a push run) 31 of 31 *both* entries PASS as prod bob and alice (its log; decision 57). The by-hand gate | ||
on hat-8 is the lead's debug run of the same 31 against prod (owner decision 18), not a number of this plan. | ||
3. Two consecutive green CI promote runs on distinct main commits: each moves stable, every `rc-operators.json` DID | ||
docs/ci-debug.md+4−4
| @@ -95,7 +95,7 @@ three checks at once, as queued; each runs once the one before it passed (owner, | ||
| Workflow | Waits for | Rents at once (4 vCPU / 8G VMs unless said) | Takes | | ||
| --- | --- | --- | --- | | ||
| `release` | nothing | the build VM, 12 vCPU / 16G | about 22 min | | ||
| `test` | `after: [release]` | the CI VM, then the staging network: atproto, gateway, 2 nested-virt bidders (5 VMs, 20 vCPU / 40G; the entries' guests run inside the bidder VMs) | about 2 h 40 min: 9 min stand-up, then 46 entries | | ||
| `test` | `after: [release]` | the CI VM, then the staging network: atproto, gateway, 2 nested-virt bidders (5 VMs, 20 vCPU / 40G; the entries' guests run inside the bidder VMs) | about 2 h 40 min: 9 min stand-up, then 47 entries | | ||
| `promote` | `after: [release, test]` | the release VM, then the prod gate's rentals: two drivers (bob, alice), at most two entries at once, at most 6 VMs of their weights (2 vCPU / 4G each by default); 0001 alone: one k8s node per bidder | about 100 min: deploy and heartbeats, then 31 entries (about 4840 s scheduled from entries.txt, 5300 to 5800 s expected; three drivers measured 3142 to 4237 s) | | ||
| ||
So about 4 h 15 min a cycle. A VM commits its memory plus a tenth (at least 512M): 8.8 GiB for 8G, 4.5 GiB for 4G. The | ||
| @@ -172,7 +172,7 @@ CI, for a commit: | ||
| ||
```sh | ||
U=knotless://socialweb.computer/socialweb-computer-kcp | ||
scripts/ci-staging-total.sh <sha> # test: <status> N of 46 PASS, then gate: staging: N of 46 PASS | ||
scripts/ci-staging-total.sh <sha> # test: <status> N of 47 PASS, then gate: staging: N of 47 PASS | ||
knotless run list $U --workflow test --commit <sha> --log | ||
knotless run attach $U --workflow test --commit <sha> --key ~/.tmp/ci-attach/attach_key.pub > attach.json # its frozen run | ||
# a branch: an asked run is one workflow, so ask each; test once release's new check reads running (after: waits for it then; | ||
| @@ -181,7 +181,7 @@ knotless run rerun $U --ref refs/heads/<branch> --workflow release | ||
knotless run rerun $U --ref refs/heads/<branch> --workflow test | ||
``` | ||
| ||
`scripts/ci-staging-total.sh <sha> [--wait <secs>]` exits 0 only when `test` ended success with 46 of 46; 3 while it is | ||
`scripts/ci-staging-total.sh <sha> [--wait <secs>]` exits 0 only when `test` ended success with 47 of 47; 3 while it is | ||
queued, running or has no check yet; 1 otherwise. | ||
| ||
### Shares by hand | ||
| @@ -511,7 +511,7 @@ Two loops, never mixed: | ||
| ||
| Loop | For | Takes | | ||
|---|---|---| | ||
| survey: the whole gate on a network | the number (N of 46), entries that break each other | 2 h 17 min of gate on two guest slots (hand cycle 3, three gate jobs), after 11 to 25 min of stand-up | | ||
| survey: the whole gate on a network | the number (N of 47), entries that break each other | 2 h 17 min of gate on two guest slots (hand cycle 3, three gate jobs), after 11 to 25 min of stand-up | | ||
| fix: one entry on a held network | proving one fix | minutes | | ||
| ||
1. A survey freezes nothing: `"freezeTtl": 5` in the input, with `"bidders": 2` (the network's bidder VMs `bidder-1` | ||
internal/app/marketnetwork/childvm.go+2−1
| @@ -50,8 +50,9 @@ func ChildVM(app v1alpha1.NetworkApp, l devinstance.Layout, parent devinstance.R | ||
if k.StopGraceSeconds > 0 { | ||
grace = strconv.Itoa(int(k.StopGraceSeconds)) + "s" | ||
} | ||
guestNetwork := app.GuestNetwork.EffectiveFor(app.Policy) | ||
vm := &devinstance.VMRuntime{Handle: KcpHandle(app), Backend: backend, ImageSource: k.GuestImageSource, StopGrace: grace, | ||
RuntimeDir: l.RuntimeDir, Executables: map[string]string{}} | ||
RuntimeDir: l.RuntimeDir, Executables: map[string]string{}, GuestNetwork: &guestNetwork} | ||
vm.VMM = vmruntime.DefaultVMM() | ||
if parent.Executables[vmruntime.VMMExecutable(vm.VMM)].Path == "" && parent.Executables["firecracker"].Path != "" { | ||
vm.VMM = vmruntime.VMMFirecracker | ||
internal/compute/firecracker/firecracker.go+63−4
| @@ -52,6 +52,8 @@ type Placement interface { | ||
type Config struct { | ||
Handle string | ||
| ||
GuestNetwork *v1alpha1.GuestNetworkStatus | ||
| ||
Log *slog.Logger | ||
} | ||
| ||
| @@ -82,12 +84,16 @@ type Provider struct { | ||
| ||
handle string | ||
| ||
guestNetwork *v1alpha1.GuestNetworkStatus | ||
| ||
log *slog.Logger | ||
| ||
procs host.Processes | ||
| ||
mu sync.Mutex | ||
| ||
rewired map[string]string | ||
| ||
exits map[string]hostsvc.UnitStatus | ||
| ||
follows map[string]*follow | ||
| @@ -121,6 +127,7 @@ func New(cfg Config, deps Deps) (*Provider, error) { | ||
log = slog.New(slog.DiscardHandler) | ||
} | ||
return &Provider{rt: deps.Runtime, m: deps.Units, userData: deps.UserData, placement: deps.Placement, procs: deps.Processes, handle: cfg.Handle, | ||
guestNetwork: cfg.GuestNetwork, rewired: map[string]string{}, | ||
log: log.With("backend", v1alpha1.BackendKindFirecrackerVM, "handle", cfg.Handle), exits: map[string]hostsvc.UnitStatus{}, | ||
follows: map[string]*follow{}, vmmExits: make(chan string, VMMExitsBuffer)}, nil | ||
} | ||
| @@ -148,6 +155,51 @@ func webrtcUDPPorts(r *v1alpha1.GuestUDPPortRange) *guestnet.PortRange { | ||
return &guestnet.PortRange{Min: int(r.Min), Max: int(r.Max)} | ||
} | ||
| ||
func (p *Provider) networkOf(vm *v1alpha1.FirecrackerVM) vmruntime.VMSpec { | ||
g := vm.Spec.GuestNetwork | ||
spec := vmruntime.VMSpec{Handle: vm.Spec.Owner.Handle, Name: vm.Name, HostPorts: hostPorts(vm.Spec.HostPorts), LANUDP: g.LANUDPAllowed(), | ||
HostUDP: g.HostUDPAllowed(), WebRTCUDPPort: int(g.WebRTCUDPPortOf()), WebRTCUDPPorts: webrtcUDPPorts(g.WebRTCUDPPortsOf()), NetworkTCP: g.NetworkTCPOf()} | ||
if b := p.guestNetwork; b != nil { | ||
spec.LANUDP, spec.HostUDP, spec.WebRTCUDPPorts = b.LANUDP, b.HostUDP, webrtcUDPPorts(b.WebRTCUDPPorts) | ||
} | ||
return spec | ||
} | ||
| ||
func rewireKey(ref vmruntime.RuntimeRef, spec vmruntime.VMSpec) string { | ||
return fmt.Sprintf("%s %d %d %v %t %t %d %v %v", ref.InvocationID, ref.PID, ref.StartTicks, spec.HostPorts, spec.LANUDP, spec.HostUDP, | ||
spec.WebRTCUDPPort, portRange(spec.WebRTCUDPPorts), spec.NetworkTCP) | ||
} | ||
| ||
func portRange(r *guestnet.PortRange) string { | ||
if r == nil { | ||
return "" | ||
} | ||
return fmt.Sprintf("%d-%d", r.Min, r.Max) | ||
} | ||
| ||
func (p *Provider) Rewire(ctx context.Context, vm *v1alpha1.FirecrackerVM) error { | ||
ref, spec := p.RefOf(vm), p.networkOf(vm) | ||
key := rewireKey(ref, spec) | ||
p.mu.Lock() | ||
done := p.rewired[vm.Name] == key | ||
p.mu.Unlock() | ||
if done { | ||
return nil | ||
} | ||
w, err := p.rt.Rewire(ctx, ref, spec) | ||
if err != nil { | ||
p.log.Warn("guest_rules_reload_failed", "firecrackervm", vm.Name, "unit", ref.Unit, "vmmPid", ref.PID, "err", err.Error()) | ||
return fmt.Errorf("firecracker: reloading the nf_tables rules of %s: %w", vm.Name, err) | ||
} | ||
p.mu.Lock() | ||
p.rewired[vm.Name] = key | ||
p.mu.Unlock() | ||
p.log.Info("guest_rules_reloaded", "firecrackervm", vm.Name, "unit", ref.Unit, "vmmPid", ref.PID, "invocation", ref.InvocationID, | ||
"table", guestnet.FenceTable, "hostPorts", w.HostPorts, "lanUDP", w.LANUDP, "hostUDP", w.HostUDP, "webrtcUDPPort", w.WebRTCUDPPort, | ||
"webrtcUDPPorts", portRange(w.WebRTCUDPPorts), "networkTCP", w.NetworkTCP, "hostAddresses", w.HostAddresses) | ||
return nil | ||
} | ||
| ||
func hostPorts(ports []int32) []int { | ||
out := make([]int, 0, len(ports)) | ||
for _, p := range ports { | ||
| @@ -364,10 +416,9 @@ func (p *Provider) Boot(ctx context.Context, vm *v1alpha1.FirecrackerVM, write f | ||
return st, err | ||
} | ||
started := time.Now() | ||
prep, err := p.rt.Prepare(ctx, vmruntime.VMSpec{Handle: h, Name: vm.Name, UserData: userData, Vcpu: int(vm.Spec.Vcpu), MemMiB: mem, DiskMiB: disk, | ||
HostPorts: hostPorts(vm.Spec.HostPorts), LANUDP: vm.Spec.GuestNetwork.LANUDPAllowed(), | ||
HostUDP: vm.Spec.GuestNetwork.HostUDPAllowed(), WebRTCUDPPort: int(vm.Spec.GuestNetwork.WebRTCUDPPortOf()), | ||
WebRTCUDPPorts: webrtcUDPPorts(vm.Spec.GuestNetwork.WebRTCUDPPortsOf()), NetworkTCP: vm.Spec.GuestNetwork.NetworkTCPOf(), Image: requestedImage(vm.Spec.Image)}) | ||
spec := p.networkOf(vm) | ||
spec.UserData, spec.Vcpu, spec.MemMiB, spec.DiskMiB, spec.Image = userData, int(vm.Spec.Vcpu), mem, disk, requestedImage(vm.Spec.Image) | ||
prep, err := p.rt.Prepare(ctx, spec) | ||
if err != nil { | ||
st = p.fail(ctx, vm, st, err) | ||
if errors.Is(err, guestimage.ErrRequestedRefused) { | ||
| @@ -399,6 +450,11 @@ func (p *Provider) Boot(ctx context.Context, vm *v1alpha1.FirecrackerVM, write f | ||
return p.fail(ctx, vm, st, err), nil | ||
} | ||
log.Info("running", "unit", ref.Unit, "vmmPid", ref.PID, "slot", ref.Slot, "vmmUid", ref.VMMUID, "invocation", ref.InvocationID) | ||
if !placedBefore { | ||
p.mu.Lock() | ||
p.rewired[vm.Name] = rewireKey(ref, placed.Spec) | ||
p.mu.Unlock() | ||
} | ||
return runningStatus(st, vm.Generation, ref), nil | ||
} | ||
| ||
| @@ -473,6 +529,9 @@ func dirSize(path string) int64 { | ||
} | ||
| ||
func (p *Provider) teardown(ctx context.Context, name, unit string) error { | ||
p.mu.Lock() | ||
delete(p.rewired, name) | ||
p.mu.Unlock() | ||
if err := p.placement.Unplace(ctx, name); err != nil { | ||
return err | ||
} | ||