Skip to content

Commit

Permalink
Merge pull request #14461 from johngmyers/ipv6-fix
Browse files Browse the repository at this point in the history
ipv6: Tolerate multiple routes to the same NAT Gateway
  • Loading branch information
k8s-ci-robot authored Oct 27, 2022
2 parents ad9c9fc + 71246db commit 85036d2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/kops/delete_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func RunDeleteCluster(ctx context.Context, f *util.Factory, out io.Writer, optio
}
}

klog.Info("Looking for cloud resources to delete")
allResources, err := resourceops.ListResources(cloud, cluster, options.Region)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ func ListIAMRoles(cloud fi.Cloud, clusterName string) ([]*resources.Resource, er

continue
} else if awsup.AWSErrorCode(err) == iam.ErrCodeNoSuchEntityException {
klog.Warningf("could not find instance profile %q. Resource may already have been deleted: %v", name, awserror)
klog.Warningf("could not find role %q. Resource may already have been deleted: %v", name, awserror)
continue
}
}
Expand Down
4 changes: 3 additions & 1 deletion upup/pkg/fi/cloudup/awstasks/natgateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,11 @@ func findNatGatewayFromRouteTable(cloud awsup.AWSCloud, routeTable *RouteTable)

if rt != nil {
var natGatewayIDs []*string
natGatewayIDsSeen := map[string]bool{}
for _, route := range rt.Routes {
if route.NatGatewayId != nil {
if route.NatGatewayId != nil && !natGatewayIDsSeen[*route.NatGatewayId] {
natGatewayIDs = append(natGatewayIDs, route.NatGatewayId)
natGatewayIDsSeen[*route.NatGatewayId] = true
}
}

Expand Down
19 changes: 17 additions & 2 deletions upup/pkg/fi/cloudup/awsup/aws_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -2271,15 +2271,20 @@ func (c *awsCloudImplementation) DefaultInstanceType(cluster *kops.Cluster, ig *
case kops.InstanceGroupRoleMaster, kops.InstanceGroupRoleNode, kops.InstanceGroupRoleAPIServer:
// t3.medium is the cheapest instance with 4GB of mem, unlimited by default, fast and has decent network
// c5.large and c4.large are a good second option in case t3.medium is not available in the AZ
candidates = []string{"t3.medium", "c5.large", "c4.large"}
candidates = []string{"t3.medium", "c5.large", "c4.large", "t4g.medium"}

case kops.InstanceGroupRoleBastion:
candidates = []string{"t3.micro", "t2.micro"}
candidates = []string{"t3.micro", "t2.micro", "t4g.micro"}

default:
return "", fmt.Errorf("unhandled role %q", ig.Spec.Role)
}

imageArch := "x86_64"
if imageInfo, err := c.ResolveImage(ig.Spec.Image); err == nil {
imageArch = fi.StringValue(imageInfo.Architecture)
}

// Find the AZs the InstanceGroup targets
igZones, err := model.FindZonesForInstanceGroup(cluster, ig)
if err != nil {
Expand All @@ -2289,6 +2294,16 @@ func (c *awsCloudImplementation) DefaultInstanceType(cluster *kops.Cluster, ig *

// TODO: Validate that instance type exists in all AZs, but skip AZs that don't support any VPC stuff
for _, instanceType := range candidates {
if strings.HasPrefix(instanceType, "t4g") {
if imageArch != "arm64" {
continue
}
} else {
if imageArch == "arm64" {
continue
}
}

zones, err := c.zonesWithInstanceType(instanceType)
if err != nil {
return "", err
Expand Down

0 comments on commit 85036d2

Please sign in to comment.