You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Docker's ContainerStats API with stream=true in the Docker driver, the PreCPUStats field in the returned stats is always zero/empty, causing incorrect CPU usage calculations.
The issue occurs in drivers/docker/stats.go when calling:
This results in inaccurate CPU usage metrics and resource utilization reporting, as the previous CPU statistics are required for calculating the correct CPU usage percentages.
Reproduction steps
Configure a Nomad client with the Docker driver
Run any Docker-based Nomad job
Examine the stats collection code path in the Docker driver
Observe that when stream=true is used, the PreCPUStats values are consistently zero/empty
Expected Result
The Docker stats API should return valid PreCPUStats data regardless of whether streaming mode is enabled or not, allowing for accurate CPU usage calculations.
Actual Result
When stream=true is used:
PreCPUStats fields are zero/empty
CPU usage calculations are incorrect due to missing previous CPU statistics
Resource utilization reporting is inaccurate
Job file (if appropriate)
This issue is reproducible with any Docker-based job, as it's related to the Docker driver's stats collection mechanism rather than specific job configurations.
Additional Context
Currently, the only workaround is to use stream=false, which returns correct PreCPUStats values but may not be optimal for continuous monitoring. This appears to be related to how Docker's stats API handles the streaming mode, where it omits the previous CPU stats in the streaming response.
The issue impacts:
CPU usage monitoring accuracy
Resource utilization reporting
Potential CPU quota enforcement
The text was updated successfully, but these errors were encountered:
Nomad version
Nomad v1.9.4-dev
Operating system and Environment details
Issue
When using Docker's ContainerStats API with
stream=true
in the Docker driver, thePreCPUStats
field in the returned stats is always zero/empty, causing incorrect CPU usage calculations.The issue occurs in
drivers/docker/stats.go
when calling:This results in inaccurate CPU usage metrics and resource utilization reporting, as the previous CPU statistics are required for calculating the correct CPU usage percentages.
Reproduction steps
stream=true
is used, thePreCPUStats
values are consistently zero/emptyExpected Result
The Docker stats API should return valid
PreCPUStats
data regardless of whether streaming mode is enabled or not, allowing for accurate CPU usage calculations.Actual Result
When
stream=true
is used:PreCPUStats
fields are zero/emptyJob file (if appropriate)
This issue is reproducible with any Docker-based job, as it's related to the Docker driver's stats collection mechanism rather than specific job configurations.
Additional Context
Currently, the only workaround is to use
stream=false
, which returns correctPreCPUStats
values but may not be optimal for continuous monitoring. This appears to be related to how Docker's stats API handles the streaming mode, where it omits the previous CPU stats in the streaming response.The issue impacts:
The text was updated successfully, but these errors were encountered: