diff --git a/cluster-autoscaler/cloudprovider/aws/aws_cloud_provider_test.go b/cluster-autoscaler/cloudprovider/aws/aws_cloud_provider_test.go index 1ce00b83b217..587833779335 100644 --- a/cluster-autoscaler/cloudprovider/aws/aws_cloud_provider_test.go +++ b/cluster-autoscaler/cloudprovider/aws/aws_cloud_provider_test.go @@ -134,8 +134,7 @@ func testProvider(t *testing.T, m *AwsManager) *awsCloudProvider { map[string]int64{cloudprovider.ResourceNameCores: 1, cloudprovider.ResourceNameMemory: 10000000}, map[string]int64{cloudprovider.ResourceNameCores: 10, cloudprovider.ResourceNameMemory: 100000000}) - instanceTypes, _ := GetStaticEC2InstanceTypes() - provider, err := BuildAwsCloudProvider(m, instanceTypes, resourceLimiter) + provider, err := BuildAwsCloudProvider(m, resourceLimiter) assert.NoError(t, err) return provider.(*awsCloudProvider) } @@ -145,8 +144,7 @@ func TestBuildAwsCloudProvider(t *testing.T) { map[string]int64{cloudprovider.ResourceNameCores: 1, cloudprovider.ResourceNameMemory: 10000000}, map[string]int64{cloudprovider.ResourceNameCores: 10, cloudprovider.ResourceNameMemory: 100000000}) - instanceTypes, _ := GetStaticEC2InstanceTypes() - _, err := BuildAwsCloudProvider(testAwsManager, instanceTypes, resourceLimiter) + _, err := BuildAwsCloudProvider(testAwsManager, resourceLimiter) assert.NoError(t, err) } diff --git a/cluster-autoscaler/cloudprovider/aws/aws_manager_test.go b/cluster-autoscaler/cloudprovider/aws/aws_manager_test.go index 31c9e55e61e2..86e5d0ff2c37 100644 --- a/cluster-autoscaler/cloudprovider/aws/aws_manager_test.go +++ b/cluster-autoscaler/cloudprovider/aws/aws_manager_test.go @@ -303,8 +303,8 @@ func TestFetchExplicitAsgs(t *testing.T) { // #1449 Without AWS_REGION getRegion() lookup runs till timeout during tests. defer resetAWSRegion(os.LookupEnv("AWS_REGION")) os.Setenv("AWS_REGION", "fanghorn") - // fetchExplicitASGs is called at manager creation time. - m, err := createAWSManagerInternal(nil, do, &autoScalingWrapper{s, newLaunchConfigurationInstanceTypeCache()}, nil) + instanceTypes, _ := GetStaticEC2InstanceTypes() + m, err := createAWSManagerInternal(nil, do, &autoScalingWrapper{s, newLaunchConfigurationInstanceTypeCache()}, nil, instanceTypes) assert.NoError(t, err) asgs := m.asgCache.Get() @@ -332,7 +332,8 @@ func TestBuildInstanceType(t *testing.T) { // #1449 Without AWS_REGION getRegion() lookup runs till timeout during tests. defer resetAWSRegion(os.LookupEnv("AWS_REGION")) os.Setenv("AWS_REGION", "fanghorn") - m, err := createAWSManagerInternal(nil, cloudprovider.NodeGroupDiscoveryOptions{}, nil, &ec2Wrapper{s}) + instanceTypes, _ := GetStaticEC2InstanceTypes() + m, err := createAWSManagerInternal(nil, cloudprovider.NodeGroupDiscoveryOptions{}, nil, &ec2Wrapper{s}, instanceTypes) assert.NoError(t, err) asg := asg{ @@ -347,7 +348,7 @@ func TestBuildInstanceType(t *testing.T) { func TestBuildInstanceTypeMixedInstancePolicyOverride(t *testing.T) { ltName, ltVersion, instanceType := "launcher", "1", "t2.large" - instanceTypes := []string{} + instanceTypeOverrides := []string{} s := &EC2Mock{} s.On("DescribeLaunchTemplateVersions", &ec2.DescribeLaunchTemplateVersionsInput{ @@ -365,14 +366,15 @@ func TestBuildInstanceTypeMixedInstancePolicyOverride(t *testing.T) { defer resetAWSRegion(os.LookupEnv("AWS_REGION")) os.Setenv("AWS_REGION", "fanghorn") - m, err := createAWSManagerInternal(nil, cloudprovider.NodeGroupDiscoveryOptions{}, nil, &ec2Wrapper{s}) + instanceTypes, _ := GetStaticEC2InstanceTypes() + m, err := createAWSManagerInternal(nil, cloudprovider.NodeGroupDiscoveryOptions{}, nil, &ec2Wrapper{s}, instanceTypes) assert.NoError(t, err) lt := &launchTemplate{name: ltName, version: ltVersion} asg := asg{ MixedInstancesPolicy: &mixedInstancesPolicy{ launchTemplate: lt, - instanceTypesOverrides: instanceTypes, + instanceTypesOverrides: instanceTypeOverrides, }, } @@ -384,25 +386,26 @@ func TestBuildInstanceTypeMixedInstancePolicyOverride(t *testing.T) { func TestBuildInstanceTypeMixedInstancePolicyNoOverride(t *testing.T) { ltName, ltVersion := "launcher", "1" - instanceTypes := []string{"m4.xlarge", "m5.xlarge"} + instanceTypeOverrides := []string{"m4.xlarge", "m5.xlarge"} defer resetAWSRegion(os.LookupEnv("AWS_REGION")) os.Setenv("AWS_REGION", "fanghorn") - m, err := createAWSManagerInternal(nil, cloudprovider.NodeGroupDiscoveryOptions{}, nil, &ec2Wrapper{}) + instanceTypes, _ := GetStaticEC2InstanceTypes() + m, err := createAWSManagerInternal(nil, cloudprovider.NodeGroupDiscoveryOptions{}, nil, &ec2Wrapper{}, instanceTypes) assert.NoError(t, err) lt := &launchTemplate{name: ltName, version: ltVersion} asg := asg{ MixedInstancesPolicy: &mixedInstancesPolicy{ launchTemplate: lt, - instanceTypesOverrides: instanceTypes, + instanceTypesOverrides: instanceTypeOverrides, }, } builtInstanceType, err := m.buildInstanceType(&asg) assert.NoError(t, err) - assert.Equal(t, instanceTypes[0], builtInstanceType) + assert.Equal(t, instanceTypeOverrides[0], builtInstanceType) } func TestGetASGTemplate(t *testing.T) { @@ -456,7 +459,8 @@ func TestGetASGTemplate(t *testing.T) { // #1449 Without AWS_REGION getRegion() lookup runs till timeout during tests. defer resetAWSRegion(os.LookupEnv("AWS_REGION")) os.Setenv("AWS_REGION", "fanghorn") - m, err := createAWSManagerInternal(nil, cloudprovider.NodeGroupDiscoveryOptions{}, nil, &ec2Wrapper{s}) + instanceTypes, _ := GetStaticEC2InstanceTypes() + m, err := createAWSManagerInternal(nil, cloudprovider.NodeGroupDiscoveryOptions{}, nil, &ec2Wrapper{s}, instanceTypes) assert.NoError(t, err) asg := &asg{ @@ -538,7 +542,8 @@ func TestFetchAutoAsgs(t *testing.T) { defer resetAWSRegion(os.LookupEnv("AWS_REGION")) os.Setenv("AWS_REGION", "fanghorn") // fetchAutoASGs is called at manager creation time, via forceRefresh - m, err := createAWSManagerInternal(nil, do, &autoScalingWrapper{s, newLaunchConfigurationInstanceTypeCache()}, nil) + instanceTypes, _ := GetStaticEC2InstanceTypes() + m, err := createAWSManagerInternal(nil, do, &autoScalingWrapper{s, newLaunchConfigurationInstanceTypeCache()}, nil, instanceTypes) assert.NoError(t, err) asgs := m.asgCache.Get()