From 6f5f6ddb5358c338879ff459f65d4ef3709314ef Mon Sep 17 00:00:00 2001 From: Rahul Rangith Date: Fri, 11 Oct 2024 09:29:21 -0400 Subject: [PATCH] AWS: only cache instance requirements when needed --- .../cloudprovider/aws/auto_scaling_groups.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go b/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go index 6c34b7c726dc..6b7d1633309f 100644 --- a/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go +++ b/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go @@ -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")