Skip to content

Commit

Permalink
🐛 Fixed issue with spot instance on nodepool (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
abdheshnayak authored Feb 9, 2024
1 parent 5096586 commit 10a1fc3
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 106 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable react/destructuring-assignment */
import { useMemo } from 'react';
import { toast } from 'react-toastify';
import { NumberInput, TextInput } from '~/components/atoms/input';
import { NumberInput } from '~/components/atoms/input';
import Select from '~/components/atoms/select';
import Popup from '~/components/molecule/popup';
import { IdSelector } from '~/console/components/id-selector';
import { useConsoleApi } from '~/console/server/gql/api-provider';
import { ExtractNodeType, parseName } from '~/console/server/r-utils/common';
import { useReload } from '~/root/lib/client/helpers/reloader';
Expand All @@ -14,7 +13,6 @@ import { handleError } from '~/root/lib/utils/common';
import { Github__Com___Kloudlite___Operator___Apis___Clusters___V1__AwsPoolType as awsPoolType } from '~/root/src/generated/gql/server';
import { useOutletContext } from '@remix-run/react';
import { INodepools } from '~/console/server/gql/queries/nodepool-queries';
import Chips from '~/components/atoms/chips';
import { awsRegions } from '~/console/dummy/consts';
import { mapper } from '~/components/utils';
import { IDialogBase } from '~/console/components/types.d';
Expand Down Expand Up @@ -99,21 +97,27 @@ const Root = (props: IDialog) => {
};
case 'spot':
const plan = findNodePlan(val.instanceType);
return {
spotPool: {
cpuNode: {
vcpu: {
max: `${plan?.spotSpec.cpuMax}`,
min: `${plan?.spotSpec.cpuMin}`,
return val.nvidiaGpuEnabled
? {
gpuNode: {
instanceTypes: [plan?.value],
},
memoryPerVcpu: {
max: `${plan?.spotSpec.memMax}`,
min: `${plan?.spotSpec.memMin}`,
}
: {
spotPool: {
cpuNode: {
vcpu: {
max: `${plan?.spotSpec.cpuMax}`,
min: `${plan?.spotSpec.cpuMin}`,
},
memoryPerVcpu: {
max: `${plan?.spotSpec.memMax}`,
min: `${plan?.spotSpec.memMin}`,
},
},
nodes: {},
},
},
nodes: {},
},
};
};
default:
return {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
parseUpdateOrCreatedBy,
parseUpdateOrCreatedOn,
} from '~/console/server/r-utils/common';
import { useState } from 'react';
import { memo, useState } from 'react';
import Popup from '~/components/molecule/popup';
import { HighlightJsLogs } from 'react-highlightjs-logs';
import { yamlDump } from '~/console/components/diff-viewer';
Expand All @@ -34,7 +34,10 @@ import { ISetState } from '~/console/page-components/app-states';
import { Button } from '~/components/atoms/button';
import { dayjs } from '~/components/molecule/dayjs';
import HandleNodePool from './handle-nodepool';
import { findNodePlanWithCategory } from './nodepool-utils';
import {
findNodePlanWithCategory,
findNodePlanWithSpec,
} from './nodepool-utils';
import { IAccountContext } from '../../../_layout';

const RESOURCE_NAME = 'nodepool';
Expand Down Expand Up @@ -138,9 +141,34 @@ const ListDetail = (
const iconSize = 14;
switch (cloudProvider) {
case 'aws':
const nodePlan = findNodePlanWithCategory(
let nodePlan = findNodePlanWithCategory(
aws?.ec2Pool?.instanceType || ''
);

if (aws?.poolType === 'spot') {
nodePlan = findNodePlanWithSpec({
spot: true,
spec: {
cpu: aws.spotPool?.cpuNode?.vcpu.min,
memory: aws.spotPool?.cpuNode?.memoryPerVcpu?.min,
},
});
<div className="flex flex-col gap-sm">
<div className="bodySm text-text-soft pulsable">
{nodePlan?.category} - {nodePlan?.labelDetail.size}
</div>
<div className="flex flex-row gap-lg bodyMd-medium pulsable">
<span className="flex flex-row gap-md items-center">
<Cpu size={iconSize} /> <span>{nodePlan?.labelDetail.cpu}</span>
</span>
<span className="flex flex-row gap-md items-center">
<Cpu size={iconSize} />{' '}
<span>{nodePlan?.labelDetail.memory}</span>
</span>
</div>
</div>;
}

return (
<div className="flex flex-col gap-sm">
<div className="bodySm text-text-soft pulsable">
Expand Down
Loading

0 comments on commit 10a1fc3

Please sign in to comment.