-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add decimal precision to CPU and memory metrics in pod info #2221
base: main
Are you sure you want to change the base?
fix: add decimal precision to CPU and memory metrics in pod info #2221
Conversation
Signed-off-by: adarsh0728 <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2221 +/- ##
==========================================
+ Coverage 63.91% 64.04% +0.13%
==========================================
Files 338 338
Lines 41085 41101 +16
==========================================
+ Hits 26259 26325 +66
+ Misses 13756 13713 -43
+ Partials 1070 1063 -7 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Currently, Container Info's CPU/Mem usage and HexagonHeatMap(container level usage) comes from |
Signed-off-by: adarsh0728 <[email protected]>
@@ -1684,3 +1684,24 @@ func (h *handler) getContainerStatus(state corev1.ContainerState) string { | |||
return "Unknown" | |||
} | |||
} | |||
|
|||
func cpuToMillicores(quantityStr string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't take Quantity
directly so that there's no need to parse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quantity is like:
quantity::= signedNumber|suffix. To get the suffix and calculate accordingly we're parsing the string.
For eg: 2847159n this is the cpuQuantity, cpuQuantity.MilliValue()
will give us 3, but we want 2.84m as our final result. For that we divide 2847159/1e6
|
||
// Parse the quantity string | ||
if _, err := fmt.Sscanf(quantityStr, "%f%s", &value, &format); err != nil { | ||
fmt.Println("Error parsing cpu quantity string:", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's a need for error handling, return it and handle it in upper layer.
Do we need to keep 2 decimals? I think no decimal is okay. |
We already have decimals in container info box and hexagonal heat map. This is done to bring parity. Also, sometimes a pod can have only one container - in pod info we are showing lets say 3m but in container box it's 2.7m (these should be equal) |
Fixes #2225
Pod Info Box:
Changes: Only Backend changes are done in this PR as logic is completely handled in the API (
pods-info
)