Skip to content

Commit

Permalink
convert nanocores to cores (#8)
Browse files Browse the repository at this point in the history
* convert nanocores to cores
  • Loading branch information
maknop authored Sep 9, 2024
1 parent 14ab0dd commit fffd235
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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 (
<Card>
Expand Down

0 comments on commit fffd235

Please sign in to comment.