Skip to content

Commit

Permalink
AWS: only cache instance requirements when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
rrangith committed Oct 11, 2024
1 parent e193af0 commit 9075283
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,13 @@ func (m *asgCache) buildAsgFromAWS(g *autoscaling.Group) (*asg, error) {
instanceRequirementsOverrides: getInstanceTypeRequirements(g.MixedInstancesPolicy.LaunchTemplate.Overrides),
}

instanceRequirements, err := m.getInstanceRequirementsFromMixedInstancesPolicy(asg.MixedInstancesPolicy)
if err != nil {
return nil, fmt.Errorf("unable to retrieve instance requirements from mixed instance policy, err: %v", err)
if len(asg.MixedInstancesPolicy.instanceTypesOverrides) == 0 {
instanceRequirements, err := m.getInstanceRequirementsFromMixedInstancesPolicy(asg.MixedInstancesPolicy)
if err != nil {
return nil, fmt.Errorf("unable to retrieve instance requirements from mixed instance policy, err: %v", err)
}
asg.MixedInstancesPolicy.instanceRequirements = instanceRequirements
}
asg.MixedInstancesPolicy.instanceRequirements = instanceRequirements

if len(asg.MixedInstancesPolicy.instanceTypesOverrides) != 0 && asg.MixedInstancesPolicy.instanceRequirementsOverrides != nil {
return nil, fmt.Errorf("invalid setup of both instance type and instance requirements overrides configured")
Expand Down

0 comments on commit 9075283

Please sign in to comment.