fix(kubernetes): fixes calculation of pod cpu utilization
Signed-off-by: Adam Letizia <LetiziaAdam@JohnDeere.com>
This commit is contained in:
@@ -74,7 +74,7 @@ describe('PodsTable', () => {
|
||||
limitTotal: '134217728',
|
||||
},
|
||||
cpu: {
|
||||
currentUsage: 0.4966115,
|
||||
currentUsage: 0.0496,
|
||||
requestTotal: 0.05,
|
||||
limitTotal: 0.05,
|
||||
},
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('pod', () => {
|
||||
const result = podStatusToCpuUtil({
|
||||
cpu: {
|
||||
// ~50m
|
||||
currentUsage: 0.4966115,
|
||||
currentUsage: 0.0496,
|
||||
// 50m
|
||||
requestTotal: 0.05,
|
||||
// 100m
|
||||
|
||||
@@ -139,22 +139,14 @@ export const currentToDeclaredResourceToPerc = (
|
||||
export const podStatusToCpuUtil = (podStatus: ClientPodStatus): ReactNode => {
|
||||
const cpuUtil = podStatus.cpu;
|
||||
|
||||
let currentUsage: number | string = cpuUtil.currentUsage;
|
||||
|
||||
// current usage number for CPU is a different unit than request/limit total
|
||||
// this might be a bug in the k8s library
|
||||
if (typeof cpuUtil.currentUsage === 'number') {
|
||||
currentUsage = cpuUtil.currentUsage / 10;
|
||||
}
|
||||
|
||||
return (
|
||||
<SubvalueCell
|
||||
value={`requests: ${currentToDeclaredResourceToPerc(
|
||||
currentUsage,
|
||||
cpuUtil.currentUsage,
|
||||
cpuUtil.requestTotal,
|
||||
)} of ${formatMillicores(cpuUtil.requestTotal)}`}
|
||||
subvalue={`limits: ${currentToDeclaredResourceToPerc(
|
||||
currentUsage,
|
||||
cpuUtil.currentUsage,
|
||||
cpuUtil.limitTotal,
|
||||
)} of ${formatMillicores(cpuUtil.limitTotal)}`}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user