mirror of https://github.com/kubernetes/kops.git
Address review comments
This commit is contained in:
parent
fdf976809e
commit
1d6a51aff9
|
|
@ -145,7 +145,7 @@ func ListResourcesAWS(cloud awsup.AWSCloud, clusterName string) (map[string]*res
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
lts, err := FindAutoScalingLaunchTemplates(cloud, clusterName, securityGroups)
|
lts, err := FindAutoScalingLaunchTemplates(cloud, clusterName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -1179,8 +1179,8 @@ func ListAutoScalingGroups(cloud fi.Cloud, clusterName string) ([]*resources.Res
|
||||||
return resourceTrackers, nil
|
return resourceTrackers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindAutoScalingLaunchTemplates finds any launch configurations which reference the security groups
|
// FindAutoScalingLaunchTemplates finds any launch templates owned by the cluster (by tag).
|
||||||
func FindAutoScalingLaunchTemplates(cloud fi.Cloud, clusterName string, securityGroups sets.String) ([]*resources.Resource, error) {
|
func FindAutoScalingLaunchTemplates(cloud fi.Cloud, clusterName string) ([]*resources.Resource, error) {
|
||||||
c := cloud.(awsup.AWSCloud)
|
c := cloud.(awsup.AWSCloud)
|
||||||
|
|
||||||
klog.V(2).Infof("Finding all AutoScaling LaunchTemplates owned by the cluster")
|
klog.V(2).Infof("Finding all AutoScaling LaunchTemplates owned by the cluster")
|
||||||
|
|
@ -1188,8 +1188,8 @@ func FindAutoScalingLaunchTemplates(cloud fi.Cloud, clusterName string, security
|
||||||
input := &ec2.DescribeLaunchTemplatesInput{
|
input := &ec2.DescribeLaunchTemplatesInput{
|
||||||
Filters: []*ec2.Filter{
|
Filters: []*ec2.Filter{
|
||||||
{
|
{
|
||||||
Name: aws.String("tag:KubernetesCluster"),
|
Name: aws.String("tag:kubernetes.io/cluster/" + clusterName),
|
||||||
Values: []*string{aws.String(clusterName)},
|
Values: []*string{aws.String("owned")},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,15 +147,14 @@ func (t *LaunchTemplate) CheckChanges(a, e, changes *LaunchTemplate) error {
|
||||||
func (t *LaunchTemplate) FindDeletions(c *fi.Context) ([]fi.Deletion, error) {
|
func (t *LaunchTemplate) FindDeletions(c *fi.Context) ([]fi.Deletion, error) {
|
||||||
var removals []fi.Deletion
|
var removals []fi.Deletion
|
||||||
|
|
||||||
configurations, err := t.findAllLaunchTemplates(c)
|
list, err := t.findAllLaunchTemplates(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
prefix := fmt.Sprintf("%s-", fi.StringValue(t.Name))
|
for _, lt := range list {
|
||||||
for _, configuration := range configurations {
|
if aws.StringValue(lt.LaunchTemplateName) != aws.StringValue(t.Name) {
|
||||||
if strings.HasPrefix(aws.StringValue(configuration.LaunchTemplateName), prefix) {
|
removals = append(removals, &deleteLaunchTemplate{lc: lt})
|
||||||
removals = append(removals, &deleteLaunchTemplate{lc: configuration})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,7 @@ func (t *LaunchTemplate) findAllLaunchTemplates(c *fi.Context) ([]*ec2.LaunchTem
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// findLatestLaunchTemplateVersion returns the latest template
|
// findLatestLaunchTemplateVersion returns the latest template version
|
||||||
func (t *LaunchTemplate) findLatestLaunchTemplateVersion(c *fi.Context) (*ec2.LaunchTemplateVersion, error) {
|
func (t *LaunchTemplate) findLatestLaunchTemplateVersion(c *fi.Context) (*ec2.LaunchTemplateVersion, error) {
|
||||||
cloud, ok := c.Cloud.(awsup.AWSCloud)
|
cloud, ok := c.Cloud.(awsup.AWSCloud)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
||||||
|
|
@ -723,10 +723,10 @@ func findAutoscalingGroupLaunchConfiguration(c AWSCloud, g *autoscaling.Group) (
|
||||||
return "", fmt.Errorf("error finding launch template by ID: %q", id)
|
return "", fmt.Errorf("error finding launch template by ID: %q", id)
|
||||||
}
|
}
|
||||||
launchTemplate := output.LaunchTemplates[0]
|
launchTemplate := output.LaunchTemplates[0]
|
||||||
if version == "" || version == "$Default" {
|
if version == "$Latest" {
|
||||||
version = strconv.FormatInt(*launchTemplate.DefaultVersionNumber, 10)
|
|
||||||
} else {
|
|
||||||
version = strconv.FormatInt(*launchTemplate.LatestVersionNumber, 10)
|
version = strconv.FormatInt(*launchTemplate.LatestVersionNumber, 10)
|
||||||
|
} else {
|
||||||
|
version = strconv.FormatInt(*launchTemplate.DefaultVersionNumber, 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
klog.V(4).Infof("Launch Template Version used for compare: %q", version)
|
klog.V(4).Infof("Launch Template Version used for compare: %q", version)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue