Description
Issue Description
The values for percentage values reported by podman stats
can differ from the calculated values (as reported by calls to the podman API). More specifically for very small (large) percentage values the command may report much larger (smaller) values. E.g. the command would report a value of 2.384087614310953e-07
as 2.38 %.
This issue was already posted before (with a narrower scope), but not yet solved: #16025.
The reason for this seems to be a call to RemoveScientificNotationFromFloat
in floatToPercentString
(here and here).
This function (RemoveScientificNotationFromFloat
) seems to
- convert the float to a string with scientific notation (for values large or small enough),
- then remove the exponent (e.g. "2.384087614310953e-07" becomes "2.384087614310953")
- convert the string back to a float.
Note that the values are already formatted without scientific notation by floatToPercentString
and the call to RemoveScientificNotationFromFloat
actually alters the value.
I think the reason for altering the value should either be described better in the code or calls to the function RemoveScientificNotationFromFloat
(and possibly the function itself) should be removed.
My links are to code of v5.0.0-rc7 where the behavior seems still to be present. I observed small enough values to be affected for AvgCPU with podman version 3.4.4 (just like the author of #16025).
I am skipping all the following fields, as this issue should be understandable just by looking at the code.
Steps to reproduce the issue
Describe the results you received
Describe the results you expected
podman info output
-
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
No response
Additional information
No response