Skip to content

Commit

Permalink
Merge pull request #7642 from mikesplain/automated-cherry-pick-of-#74…
Browse files Browse the repository at this point in the history
…45-origin-release-1.15

Automated cherry pick of #7445: Fix that the node of the instance group of the mixed
  • Loading branch information
k8s-ci-robot authored Sep 21, 2019
2 parents c80581b + 85db77f commit bb7d611
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions upup/pkg/fi/cloudup/awsup/aws_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package awsup

import (
"fmt"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -570,7 +571,7 @@ func matchesAsgTags(tags map[string]string, actual []*autoscaling.TagDescription
}

// findAutoscalingGroupLaunchConfiguration is responsible for finding the launch - which could be a launchconfiguration, a template or a mixed instance policy template
func findAutoscalingGroupLaunchConfiguration(g *autoscaling.Group) (string, error) {
func findAutoscalingGroupLaunchConfiguration(c AWSCloud, g *autoscaling.Group) (string, error) {
name := aws.StringValue(g.LaunchConfigurationName)
if name != "" {
return name, nil
Expand All @@ -592,7 +593,23 @@ func findAutoscalingGroupLaunchConfiguration(g *autoscaling.Group) (string, erro
if g.MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification != nil {
// honestly!!
name = aws.StringValue(g.MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification.LaunchTemplateName)
version := aws.StringValue(g.MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification.Version)
request := &ec2.DescribeLaunchTemplateVersionsInput{
LaunchTemplateName: &name,
}

versions, err := c.EC2().DescribeLaunchTemplateVersions(request)
if err != nil {
return "", fmt.Errorf("error finding versions for launch template: %v", err)
}

var version string
for _, v := range versions.LaunchTemplateVersions {
if *v.DefaultVersion {
version = strconv.FormatInt(*v.VersionNumber, 10)
break
}
}

if name != "" {
launchTemplate := name + ":" + version
return launchTemplate, nil
Expand Down Expand Up @@ -625,7 +642,7 @@ func findInstanceLaunchConfiguration(i *autoscaling.Instance) string {
}

func awsBuildCloudInstanceGroup(c AWSCloud, ig *kops.InstanceGroup, g *autoscaling.Group, nodeMap map[string]*v1.Node) (*cloudinstances.CloudInstanceGroup, error) {
newConfigName, err := findAutoscalingGroupLaunchConfiguration(g)
newConfigName, err := findAutoscalingGroupLaunchConfiguration(c, g)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit bb7d611

Please sign in to comment.