Description
The NodePool list and details views read CPU with parseInt, but status.resources.cpu and spec.limits.cpu are Kubernetes resource quantities, so they can carry a suffix.
parseInt('1750m') stops at the first non-digit and returns 1750. The suffix is dropped, so 1.75 cores is displayed and charted as 1750 cores — a thousand times too large.
Memory in the same two files is already handled correctly: it goes through parseRam() and is formatted with getResourceStr(). Only CPU uses parseInt.
Karpenter itself reports these values in milli-cores whenever the amount is not a whole number of cores, which is the common case for a NodePool that has scaled up partially.
Affected code
karpenter/src/NodePool/List.tsx lines 76-77 (getValue) and 82-83 (render)
karpenter/src/NodePool/Details.tsx lines 94-95 (extraInfo)
Steps to reproduce
- Install Karpenter and let a NodePool provision nodes so that
status.resources.cpu is reported in milli-cores, for example 1750m, with spec.limits.cpu set to 8.
- Open Karpenter → NodePools.
Current behaviour
The CPU column reads 1750/8, and the percentage bar is driven by used = 1750 against total = 8, so it pins at full with a tooltip claiming 21875%.
The details view shows 1750 of 8 for the same NodePool.
Expected behaviour
The CPU column reads 1.75/8, and the bar shows roughly 22%. The details view shows 1.75 of 8.
Notes
kubeflow/src/components/common/notebookUtils.ts already has parseCpuQuantity, which converts n, u, m and plain suffixes to cores and is unit tested. The same conversion is what the karpenter plugin needs.
Description
The NodePool list and details views read CPU with
parseInt, butstatus.resources.cpuandspec.limits.cpuare Kubernetes resource quantities, so they can carry a suffix.parseInt('1750m')stops at the first non-digit and returns1750. The suffix is dropped, so 1.75 cores is displayed and charted as 1750 cores — a thousand times too large.Memory in the same two files is already handled correctly: it goes through
parseRam()and is formatted withgetResourceStr(). Only CPU usesparseInt.Karpenter itself reports these values in milli-cores whenever the amount is not a whole number of cores, which is the common case for a NodePool that has scaled up partially.
Affected code
karpenter/src/NodePool/List.tsxlines 76-77 (getValue) and 82-83 (render)karpenter/src/NodePool/Details.tsxlines 94-95 (extraInfo)Steps to reproduce
status.resources.cpuis reported in milli-cores, for example1750m, withspec.limits.cpuset to8.Current behaviour
The CPU column reads
1750/8, and the percentage bar is driven byused = 1750againsttotal = 8, so it pins at full with a tooltip claiming 21875%.The details view shows
1750 of 8for the same NodePool.Expected behaviour
The CPU column reads
1.75/8, and the bar shows roughly 22%. The details view shows1.75 of 8.Notes
kubeflow/src/components/common/notebookUtils.tsalready hasparseCpuQuantity, which convertsn,u,mand plain suffixes to cores and is unit tested. The same conversion is what the karpenter plugin needs.