Skip to content

Commit

Permalink
Ensure GPU AMI is used when using multiple instances
Browse files Browse the repository at this point in the history
  • Loading branch information
cPu1 committed Jul 2, 2021
1 parent afe0890 commit e00f72c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/eks/api.go
Expand Up @@ -346,14 +346,24 @@ func ResolveAMI(provider api.ClusterProvider, version string, np api.NodePool) e
// If the nodegroup has mixed instances it will prefer a GPU instance type over a general class one
// This is to make sure that the AMI that is selected later is valid for all the types
func selectInstanceType(np api.NodePool) string {
if ng, ok := np.(*api.NodeGroup); ok && api.HasMixedInstances(ng) {
for _, instanceType := range ng.InstancesDistribution.InstanceTypes {
var instanceTypes []string
switch ng := np.(type) {
case *api.NodeGroup:
instanceTypes = ng.InstancesDistribution.InstanceTypes
case *api.ManagedNodeGroup:
instanceTypes = ng.InstanceTypes
}

hasMixedInstances := len(instanceTypes) > 0
if hasMixedInstances {
for _, instanceType := range instanceTypes {
if utils.IsGPUInstanceType(instanceType) {
return instanceType
}
}
return ng.InstancesDistribution.InstanceTypes[0]
return instanceTypes[0]
}

return np.BaseNodeGroup().InstanceType
}

Expand Down

0 comments on commit e00f72c

Please sign in to comment.