SIGN IN SIGN UP

Deflake TestMultiContainerEvent/enableCgroupsV2

The test asserted that the exited "quick" container (/bin/true) reports
non-zero CPU usage via cgroup v2 cpu.stat. The cgroup2fs charging is
correct (exit charges are committed before the parent can reap), but
the sentry accounts task CPU time in whole 10ms clock ticks: a task
that is never running when the ticker fires accrues zero time. A
container as short-lived as /bin/true misses every tick in a few
percent of runs, making the assertion flaky.

Linux never reports 0 here only because it accounts at nanosecond
granularity.

Make the quick container burn a short burst of CPU before exiting so
that several tick boundaries land while it runs, which makes the
accumulated usage reliably non-zero. The v1 and disabled-cgroups
subtests are unaffected: the v1 events path keys ContainerUsage by
container name rather than ID, and the sentry fallback only counts
live thread groups, so both still report 0 for the exited container.

PiperOrigin-RevId: 961224935
S
Shailend Chand committed
5ceb9a5fd5750d6c73dd166441f28306039300d0
Parent: e5c18e2
Committed by gVisor bot <gvisor-bot@google.com> on 8/8/2026, 1:55:56 AM