Commit c973134
Roy Lin
fix(cri): StopPodSandbox state invariant + non-running container stats
Two confirmed bugs from the adversarial CRI audit, hand-verified:
- StopPodSandbox left the sandbox Ready if VM teardown failed. It marks all
containers Exited + removes their stream handles, then destroy_sandbox_vm(...)?
propagated an error BEFORE update_sandbox_state(NotReady) ran — so the sandbox
stayed Ready with Exited containers and a gone VM. A later CreateContainer
(which only checks the sandbox is Ready) would then attach to a sandbox whose
VM no longer exists. Mark the sandbox NotReady regardless of the destroy
result (state made consistent first), then surface the destroy error.
- container_stats / list_container_stats reported VM usage for non-running
containers. They split the pod VM's usage across containers without checking
the container is Running, so a Created/Exited container reported a full share
of CPU/memory. list_container_stats was worse: it counted ALL containers (any
state) as the divisor. Now only running containers get a usage share; others
report zero, and the divisor counts running containers only.
Also REJECTED from the same audit (hand-verified false positives): the 5
'CPU cpu_period/cpu_quota nanosecond' findings — CRI defines these as CFS
period/quota in MICROSECONDS (matching ResourceLimits + the guest cpu.max), and
critest already measures a 0.5-core limit at ~0.53; adding /1000 would have
broken working CPU limits.
clippy -D warnings clean; 237 cri unit tests pass.1 parent 6b706ca commit c973134
1 file changed
Lines changed: 39 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
700 | | - | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
701 | 706 | | |
702 | | - | |
703 | 707 | | |
704 | 708 | | |
705 | 709 | | |
| 710 | + | |
706 | 711 | | |
707 | 712 | | |
708 | 713 | | |
| |||
2383 | 2388 | | |
2384 | 2389 | | |
2385 | 2390 | | |
2386 | | - | |
2387 | | - | |
2388 | | - | |
2389 | | - | |
2390 | | - | |
2391 | | - | |
2392 | | - | |
2393 | | - | |
2394 | | - | |
2395 | | - | |
2396 | | - | |
2397 | | - | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
2398 | 2408 | | |
2399 | 2409 | | |
2400 | 2410 | | |
| |||
2440 | 2450 | | |
2441 | 2451 | | |
2442 | 2452 | | |
| 2453 | + | |
| 2454 | + | |
2443 | 2455 | | |
2444 | 2456 | | |
2445 | | - | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
2446 | 2461 | | |
2447 | 2462 | | |
2448 | 2463 | | |
| |||
2452 | 2467 | | |
2453 | 2468 | | |
2454 | 2469 | | |
2455 | | - | |
2456 | | - | |
2457 | | - | |
2458 | | - | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
2459 | 2479 | | |
2460 | 2480 | | |
2461 | 2481 | | |
| |||
0 commit comments