Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert nanocores to cores #8

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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