Skip to content

Commit 99dbf72

Browse files
authored
Skip instance type support validation for custom AMI ID (#8303)
1 parent 3798778 commit 99dbf72

3 files changed

Lines changed: 38 additions & 4 deletions

File tree

pkg/apis/eksctl.io/v1alpha5/gpu_validation_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,23 @@ var _ = Describe("GPU instance support", func() {
249249
}),
250250
)
251251

252+
Describe("No GPU instance type support validation for custom AMI", func() {
253+
amiFamily := api.NodeImageFamilyAmazonLinux2023
254+
instanceType := "g5g.2xlarge"
255+
256+
ngFail := api.NewNodeGroup()
257+
ngFail.AMIFamily = amiFamily
258+
ngFail.InstanceType = instanceType
259+
260+
ngPass := api.NewNodeGroup()
261+
ngPass.AMIFamily = amiFamily
262+
ngPass.InstanceType = instanceType
263+
ngPass.AMI = "ami-xxxx"
264+
265+
Expect(api.ValidateNodeGroup(0, ngFail, api.NewClusterConfig())).To(HaveOccurred())
266+
Expect(api.ValidateNodeGroup(0, ngPass, api.NewClusterConfig())).NotTo(HaveOccurred())
267+
})
268+
252269
DescribeTable("ARM-based GPU instance type support", func(amiFamily string, expectErr bool) {
253270
ng := api.NewNodeGroup()
254271
ng.InstanceType = "g5g.2xlarge"
@@ -261,6 +278,7 @@ var _ = Describe("GPU instance support", func() {
261278
}
262279
},
263280
Entry("AmazonLinux2", api.NodeImageFamilyAmazonLinux2, true),
281+
Entry("AmazonLinux2023", api.NodeImageFamilyAmazonLinux2023, true),
264282
Entry("Ubuntu2004", api.NodeImageFamilyUbuntu2004, true),
265283
Entry("Ubuntu1804", api.NodeImageFamilyUbuntu1804, true),
266284
Entry("Windows2019Full", api.NodeImageFamilyWindowsServer2019FullContainer, true),

pkg/apis/eksctl.io/v1alpha5/validation.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,8 @@ func ValidateNodeGroup(i int, ng *NodeGroup, cfg *ClusterConfig) error {
973973
return err
974974
}
975975

976-
if instanceutils.IsARMGPUInstanceType(SelectInstanceType(ng)) && ng.AMIFamily != NodeImageFamilyBottlerocket {
977-
return fmt.Errorf("ARM GPU instance types are not supported for unmanaged nodegroups with AMIFamily %s", ng.AMIFamily)
976+
if err := validateInstanceTypeSupport(ng); err != nil {
977+
return err
978978
}
979979

980980
if err := validateInstancesDistribution(ng); err != nil {
@@ -1045,6 +1045,23 @@ func ValidateNodeGroup(i int, ng *NodeGroup, cfg *ClusterConfig) error {
10451045
return nil
10461046
}
10471047

1048+
// validateInstanceTypeSupport checks if the provided instance types are
1049+
// supported by the AMIFamily. If a custom AMI is provided then it will skip the
1050+
// validation, as it could be a derivative of a supported family type.
1051+
func validateInstanceTypeSupport(ng *NodeGroup) error {
1052+
if IsAMI(ng.AMI) {
1053+
return nil
1054+
}
1055+
if instanceutils.IsARMGPUInstanceType(SelectInstanceType(ng)) {
1056+
switch ng.AMIFamily {
1057+
case NodeImageFamilyBottlerocket:
1058+
default:
1059+
return fmt.Errorf("ARM GPU instance types are not supported for unmanaged nodegroups with AMIFamily %s", ng.AMIFamily)
1060+
}
1061+
}
1062+
return nil
1063+
}
1064+
10481065
func validateOutpostARN(val string) error {
10491066
parsed, err := arn.Parse(val)
10501067
if err != nil {

pkg/nodebootstrap/managed_al2.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"io"
88
"mime/multipart"
9-
"strings"
109

1110
nodeadm "github.com/awslabs/amazon-eks-ami/nodeadm/api/v1alpha1"
1211
"sigs.k8s.io/yaml"
@@ -32,7 +31,7 @@ func NewManagedAL2Bootstrapper(ng *api.ManagedNodeGroup) *ManagedAL2 {
3231
func (m *ManagedAL2) UserData() (string, error) {
3332
ng := m.ng
3433

35-
if strings.HasPrefix(ng.AMI, "ami-") {
34+
if api.IsAMI(ng.AMI) {
3635
return makeCustomAMIUserData(ng.NodeGroupBase, m.UserDataMimeBoundary)
3736
}
3837

0 commit comments

Comments
 (0)