diff --git a/plugins/openshift/src/components/DeploymentsListComponent/ResourceUsageProgress.tsx b/plugins/openshift/src/components/DeploymentsListComponent/ResourceUsageProgress.tsx index 4440ae5..0c13110 100644 --- a/plugins/openshift/src/components/DeploymentsListComponent/ResourceUsageProgress.tsx +++ b/plugins/openshift/src/components/DeploymentsListComponent/ResourceUsageProgress.tsx @@ -6,7 +6,7 @@ import { Card, CardContent, Typography } from '@material-ui/core'; const ResourceUsageProgress = (resourceInfo: any) => { const resourceType = resourceInfo.resourceType; - const usage = resourceInfo.resourceUsage[resourceType]; + let usage = resourceInfo.resourceUsage[resourceType]; const isUndefined = resourceInfo.resourceLimitsRequests.requests.undefined @@ -18,6 +18,17 @@ const ResourceUsageProgress = (resourceInfo: any) => { ? resourceInfo?.resourceLimitsRequests?.requests[resourceType] : 0; + const convertNanocoresToCores = (value: number) => { + return value / 1000000000 + }; + + // cpu utilization is in nanocores + if (resourceInfo.resourceType === 'cpu') { + usage = convertNanocoresToCores(usage).toFixed(6) + } + + const usagePercentageOfRequests = Math.min((usage / requests) * 100, 100); + // Bar color is green by default let barColor = '#228B22'; // If usage is greater than 60% of the requests, but less than 90 make it yellow @@ -44,18 +55,13 @@ const ResourceUsageProgress = (resourceInfo: any) => { }, }))(LinearProgress); - const usagePercentageOfRequests = Math.min((usage / requests) * 100, 100); - const formatResourceValue = (value: number) => { if (resourceInfo.resourceType === 'memory') { return `${value.toFixed(2)} Mi`; } - return `${value.toFixed(2)} cores`; + return `${value} cores`; }; - - - const ToolTipContent = () => { return (