Skip to content

Commit

Permalink
fix(batch): remove default optimal for arm based instance types and a…
Browse files Browse the repository at this point in the history
…dd error checks (#31510)

### Issue # (if applicable)

Closes #31148

### Reason for this change
When adding an arm-based instance, optimal instance is set by default which consists of an x86-based instance. This causes errors since arm and x86 instances can't be mixed together.

### Description of changes
- useOptimalInstanceClasses is set to false for all arm-based instances
- Throws error when trying to mix x86 and arm instances
  - Case 1: Instantiating the class
  - Case 2: addInstanceClass and addInstanceType functions
- Warning useOptimalInstanceClasses is being set to false for arm-based instances

### Description of how you validated changes
- Unit test where optimal doesn't get added for arm-based instances
- Unit tests to display errors when instantiating the class
- Unit tests to display errors when addInstanceClass and addInstanceType is adding mixed instances
- Unit tests to display warning for arm based instances

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
1kaileychen authored Oct 1, 2024
1 parent b20fd8e commit 7e80cc9
Show file tree
Hide file tree
Showing 10 changed files with 492 additions and 19 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,112 @@
"UpdatePolicy": {}
}
},
"noOptimalInstancesForARMSecurityGroup7157B016": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "batch-stack/noOptimalInstancesForARM/SecurityGroup",
"SecurityGroupEgress": [
{
"CidrIp": "0.0.0.0/0",
"Description": "Allow all outbound traffic by default",
"IpProtocol": "-1"
}
],
"VpcId": {
"Ref": "vpcA2121C38"
}
}
},
"noOptimalInstancesForARMInstanceProfileRole926AEEC5": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
]
]
}
]
}
},
"noOptimalInstancesForARMInstanceProfile37BE9D32": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Roles": [
{
"Ref": "noOptimalInstancesForARMInstanceProfileRole926AEEC5"
}
]
}
},
"noOptimalInstancesForARMF146AA4D": {
"Type": "AWS::Batch::ComputeEnvironment",
"Properties": {
"ComputeResources": {
"AllocationStrategy": "BEST_FIT_PROGRESSIVE",
"Ec2Configuration": [
{
"ImageIdOverride": {
"Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter"
},
"ImageType": "ECS_AL2"
}
],
"InstanceRole": {
"Fn::GetAtt": [
"noOptimalInstancesForARMInstanceProfile37BE9D32",
"Arn"
]
},
"InstanceTypes": [
"a1.large",
"m6g"
],
"MaxvCpus": 256,
"MinvCpus": 0,
"SecurityGroupIds": [
{
"Fn::GetAtt": [
"noOptimalInstancesForARMSecurityGroup7157B016",
"GroupId"
]
}
],
"Subnets": [
{
"Ref": "vpcPrivateSubnet1Subnet934893E8"
},
{
"Ref": "vpcPrivateSubnet2Subnet7031C2BA"
}
],
"Type": "EC2"
},
"ReplaceComputeEnvironment": false,
"State": "ENABLED",
"Type": "managed",
"UpdatePolicy": {}
}
},
"taggedCESecurityGroup82CCF59F": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7e80cc9

Please sign in to comment.