mirror of https://github.com/kubernetes/kops.git
Address review comments
This commit is contained in:
parent
95b6a3f837
commit
d923354d4f
|
|
@ -115,8 +115,8 @@ func ValidateInstanceGroup(g *kops.InstanceGroup, cloud fi.Cloud) field.ErrorLis
|
|||
allErrs = append(allErrs, validateRollingUpdate(g.Spec.RollingUpdate, field.NewPath("spec", "rollingUpdate"), g.Spec.Role == kops.InstanceGroupRoleMaster)...)
|
||||
}
|
||||
|
||||
if awsCloud, ok := cloud.(awsup.AWSCloud); ok {
|
||||
allErrs = append(allErrs, awsValidateInstanceGroup(g, awsCloud)...)
|
||||
if cloud != nil && cloud.ProviderID() == kops.CloudProviderAWS {
|
||||
allErrs = append(allErrs, awsValidateInstanceGroup(g, cloud.(awsup.AWSCloud))...)
|
||||
}
|
||||
|
||||
return allErrs
|
||||
|
|
|
|||
|
|
@ -178,8 +178,7 @@ type awsCloudImplementation struct {
|
|||
|
||||
regionDelayers *RegionDelayers
|
||||
|
||||
instanceTypes map[string]*ec2.InstanceTypeInfo
|
||||
instanceTypesMutex sync.Mutex
|
||||
instanceTypes *instanceTypes
|
||||
}
|
||||
|
||||
type RegionDelayers struct {
|
||||
|
|
@ -187,6 +186,11 @@ type RegionDelayers struct {
|
|||
delayerMap map[string]*k8s_aws.CrossRequestRetryDelay
|
||||
}
|
||||
|
||||
type instanceTypes struct {
|
||||
mutex sync.Mutex
|
||||
typeMap map[string]*ec2.InstanceTypeInfo
|
||||
}
|
||||
|
||||
var _ fi.Cloud = &awsCloudImplementation{}
|
||||
|
||||
func (c *awsCloudImplementation) ProviderID() kops.CloudProviderID {
|
||||
|
|
@ -207,6 +211,9 @@ func NewAWSCloud(region string, tags map[string]string) (AWSCloud, error) {
|
|||
regionDelayers: &RegionDelayers{
|
||||
delayerMap: make(map[string]*k8s_aws.CrossRequestRetryDelay),
|
||||
},
|
||||
instanceTypes: &instanceTypes{
|
||||
typeMap: make(map[string]*ec2.InstanceTypeInfo),
|
||||
},
|
||||
}
|
||||
|
||||
config := aws.NewConfig().WithRegion(region)
|
||||
|
|
@ -288,7 +295,6 @@ func NewAWSCloud(region string, tags map[string]string) (AWSCloud, error) {
|
|||
return c, err
|
||||
}
|
||||
}
|
||||
c.instanceTypes = make(map[string]*ec2.InstanceTypeInfo)
|
||||
|
||||
awsCloudInstances[region] = c
|
||||
raw = c
|
||||
|
|
@ -1547,17 +1553,17 @@ func (c *awsCloudImplementation) zonesWithInstanceType(instanceType string) (set
|
|||
|
||||
// DescribeInstanceType calls ec2.DescribeInstanceType to get information for a particular instance type
|
||||
func (c *awsCloudImplementation) DescribeInstanceType(instanceType string) (*ec2.InstanceTypeInfo, error) {
|
||||
if info, ok := c.instanceTypes[instanceType]; ok {
|
||||
if info, ok := c.instanceTypes.typeMap[instanceType]; ok {
|
||||
return info, nil
|
||||
}
|
||||
c.instanceTypesMutex.Lock()
|
||||
defer c.instanceTypesMutex.Unlock()
|
||||
c.instanceTypes.mutex.Lock()
|
||||
defer c.instanceTypes.mutex.Unlock()
|
||||
|
||||
info, err := describeInstanceType(c, instanceType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.instanceTypes[instanceType] = info
|
||||
c.instanceTypes.typeMap[instanceType] = info
|
||||
return info, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue