fix: visualize CPU and Memory usage with LineProgress in pod list#1556
fix: visualize CPU and Memory usage with LineProgress in pod list#1556omarluq merged 2 commits intofreelensapp:mainfrom
Conversation
… getTableRow method to simplify parameters
omarluq
left a comment
There was a problem hiding this comment.
LGTM thank you for fixing this ❤️ the comment is to address an edge case that your fix exposes but doesn't block your pr
| getTableRow(uid: string) { | ||
| const { pods, owner, podStore, showDetails } = this.props; |
There was a problem hiding this comment.
When testing I found an edge case unrelated to this fix stemming from getPodKubeMetrics:
pods in terminal states (Succeeded or Failed), which never have metrics reported, as well as
pods for which metrics have not yet been collected, result in { cpu: NaN, memory: NaN }.
These NaN values then propagate into the UI.
We have a few options to fix this:
- UI-level guard (in
getTableRow), i.e.
const { cpu, memory } = podStore.getPodKubeMetrics(pod) ?? {};
const safeCpu = Number.isFinite(cpu) ? cpu : 0;
const safeMemory = Number.isFinite(memory) ? memory : 0; -
Store-level fix: never return
NaNfromgetPodKubeMetrics. Treat “no metrics available” as 0 usage. -
Store-level fix: return
nullto represent “unknown”. This is more semantically correct, but requires UI changes to display and handle sorting
close: #851