Skip to content

Commit 5328977

Browse files
committed
Add feedback from tmokmss
1 parent a59e7d6 commit 5328977

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

packages/aws-cdk-lib/aws-eks/lib/cluster.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,16 +1818,13 @@ export class Cluster extends ClusterBase {
18181818
* @param options options for creating a new nodegroup
18191819
*/
18201820
public addNodegroupCapacity(id: string, options?: NodegroupOptions): Nodegroup {
1821-
const hasInferentiaInstanceType = [
1821+
const hasInferentiaOrTraniumInstanceType = [
18221822
options?.instanceType,
18231823
...options?.instanceTypes ?? [],
1824-
].some(i => i && nodeTypeForInstanceType(i) === NodeType.INFERENTIA);
1825-
const hasTrainiumInstanceType = [
1826-
options?.instanceType,
1827-
...options?.instanceTypes ?? [],
1828-
].some(i => i && nodeTypeForInstanceType(i) === NodeType.TRAINIUM);
1824+
].some(i => i && (nodeTypeForInstanceType(i) === NodeType.INFERENTIA ||
1825+
nodeTypeForInstanceType(i) === NodeType.TRAINIUM));
18291826

1830-
if (hasInferentiaInstanceType || hasTrainiumInstanceType) {
1827+
if (hasInferentiaOrTraniumInstanceType) {
18311828
this.addNeuronDevicePlugin();
18321829
}
18331830
return new Nodegroup(this, `Nodegroup${id}`, {
@@ -2483,10 +2480,14 @@ export enum MachineImageType {
24832480
}
24842481

24852482
function nodeTypeForInstanceType(instanceType: ec2.InstanceType) {
2486-
return INSTANCE_TYPES.gpu.includes(instanceType.toString().substring(0, 2)) ? NodeType.GPU :
2487-
INSTANCE_TYPES.inferentia.includes(instanceType.toString().substring(0, 4)) ? NodeType.INFERENTIA :
2488-
INSTANCE_TYPES.trainium.includes(instanceType.toString().substring(0, 4)) ? NodeType.TRAINIUM :
2489-
NodeType.STANDARD;
2483+
if (INSTANCE_TYPES.gpu.includes(instanceType.toString().substring(0, 2))) {
2484+
return NodeType.GPU;
2485+
} else if (INSTANCE_TYPES.inferentia.includes(instanceType.toString().substring(0, 4))) {
2486+
return NodeType.INFERENTIA;
2487+
} else if (INSTANCE_TYPES.trainium.includes(instanceType.toString().substring(0, 4))) {
2488+
return NodeType.TRAINIUM;
2489+
}
2490+
return NodeType.STANDARD;
24902491
}
24912492

24922493
function cpuArchForInstanceType(instanceType: ec2.InstanceType) {

0 commit comments

Comments
 (0)