Commit 8794cb5
Roy Lin
fix(box): run the log processor in the shim (box-lifetime), not the CLI
Detached `run -d` boxes truncated their logs: the json-file/syslog processor
was a tokio spawn_blocking task in the EPHEMERAL launching CLI, which exits on
detach — so container.json only ever got the lines written before the CLI left
(reliably repro'd: `echo early; sleep 5; echo late` captured only 'early').
Move the processor to the SHIM — the box's own per-process lifetime that already
writes console.log. This is the daemonless home (like containerd-shim): it works
identically for foreground and detached, with no daemon dependency, and drains
the final lines on teardown.
- core/log.rs: moved the sync processing engine here (run_log_processor +
json-file/syslog/RotatingWriter/tail_next_line), keyed off a `stop` flag.
When the VM exits the shim sets stop, the processor drains to EOF (flushing a
trailing partial line) and returns — no last-line teardown race. (start_enter
DOES return the guest status, despite the legacy 'never returns' comment.)
- core/vmm.rs: InstanceSpec gains log_config (serialized to the shim).
- shim/main.rs: spawn the processor thread before start_enter; stop+join after.
- runtime/vm: VmManager carries log_config (set_log_config); spec threads it.
- runtime/log.rs: now just re-exports json_log_path/is_runtime_console_noise.
- cli: set_log_config on the VM; removed the 3 ephemeral CLI spawns.
KVM-verified: detached `early; sleep 5; late` -> BOTH lines, timestamps ~5s
apart (so --timestamps now shows REAL per-line emission time too); last-line
before exit preserved; logs still clean (noise=0); exit code 7 propagates; exec
unaffected; no VM leak. Known separate/pre-existing gap: foreground non-`--rm`
boxes wipe their dir (logs included) on destroy, so `logs` after a foreground
run is empty — orthogonal to this fix; tracked for follow-up.1 parent 6a870f6 commit 8794cb5
12 files changed
Lines changed: 411 additions & 453 deletions
File tree
- src
- cli/src
- commands
- core
- src
- runtime/src
- vm
- shim/src
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
192 | 194 | | |
193 | 195 | | |
194 | 196 | | |
| |||
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
217 | 214 | | |
218 | 215 | | |
219 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
623 | 619 | | |
624 | 620 | | |
625 | 621 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
191 | 194 | | |
192 | 195 | | |
193 | 196 | | |
| |||
376 | 379 | | |
377 | 380 | | |
378 | 381 | | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
384 | 386 | | |
385 | 387 | | |
386 | 388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
0 commit comments