Fix reported CPU usage on Podman - #200
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan includes up to 2 reviews per rolling hour; 1 remains after this review. 📝 WalkthroughWalkthroughResource polling caches Podman runtime detection and selects runtime-specific CPU calculations. Docker uses ChangesPodman CPU statistics
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The PR changes CPU usage calculation for Podman while retaining Docker behavior and adds targeted tests; no actionable merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant ResourcePolling
participant DockerAPI
participant CPUCalculation
ResourcePolling->>DockerAPI: detect runtime from Engine version
DockerAPI-->>ResourcePolling: return version components
ResourcePolling->>DockerAPI: read container stats
DockerAPI-->>ResourcePolling: return stats sample
ResourcePolling->>CPUCalculation: calculate absolute CPU with runtime flag
CPUCalculation-->>ResourcePolling: return CPU usage
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@MatthewCash Can you fix the merge conflict here please? |
# Conflicts: # environment/docker/stats.go
|
I've fixed the merge conflict. But... I think instead we should just do wall-time only, because Docker's formula effectively reduces to the same math anyway, so both runtimes would report identical numbers with one code path. That lets us delete the runtime detection entirely, which is where the real problems are, since the version probe holds a global lock across a network call and a transient failure would silently leave a server on the wrong formula. |
This fixes incorrect CPU usage reporting when Wings uses Podman. Podman does not provide Docker-equivalent system CPU values, so CPU usage is now calculated using elapsed wall time instead.
Docker retains its existing calculation, and the container runtime is detected automatically.
I added some tests to cover the Docker and Podman calculations, multi-core usage, counter resets, invalid timestamps, and runtime detection.
Summary by CodeRabbit