Skip to content

Commit

Permalink
aws: Skip Route53 cleanup for clusters without DNS
Browse files Browse the repository at this point in the history
  • Loading branch information
hakman committed Dec 2, 2022
1 parent 361b9af commit 102237a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions pkg/resources/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/aws/aws-sdk-go/service/route53"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/klog/v2"
"k8s.io/kops/pkg/dns"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/featureflag"
"k8s.io/kops/pkg/resources"
"k8s.io/kops/pkg/resources/spotinst"
Expand All @@ -50,7 +50,8 @@ const (

type listFn func(fi.Cloud, string) ([]*resources.Resource, error)

func ListResourcesAWS(cloud awsup.AWSCloud, clusterName string) (map[string]*resources.Resource, error) {
func ListResourcesAWS(cloud awsup.AWSCloud, cluster *kopsapi.Cluster) (map[string]*resources.Resource, error) {
clusterName := cluster.Name
resourceTrackers := make(map[string]*resources.Resource)

// These are the functions that are used for looking up
Expand All @@ -75,8 +76,6 @@ func ListResourcesAWS(cloud awsup.AWSCloud, clusterName string) (map[string]*res
ListELBV2s,
ListTargetGroups,

// Route 53
ListRoute53Records,
// IAM
ListIAMInstanceProfiles,
ListIAMRoles,
Expand All @@ -88,6 +87,11 @@ func ListResourcesAWS(cloud awsup.AWSCloud, clusterName string) (map[string]*res
ListEventBridgeRules,
}

if !cluster.IsGossip() || !cluster.UsesNoneDNS() {
// Route 53
listFunctions = append(listFunctions, ListRoute53Records)
}

if featureflag.Spotinst.Enabled() {
// Spotinst resources
listFunctions = append(listFunctions, ListSpotinstResources)
Expand Down Expand Up @@ -1768,10 +1772,6 @@ func deleteRoute53Records(cloud fi.Cloud, zone *route53.HostedZone, resourceTrac
func ListRoute53Records(cloud fi.Cloud, clusterName string) ([]*resources.Resource, error) {
var resourceTrackers []*resources.Resource

if dns.IsGossipClusterName(clusterName) {
return resourceTrackers, nil
}

c := cloud.(awsup.AWSCloud)

// Normalize cluster name, with leading "."
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/ops/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func ListResources(cloud fi.Cloud, cluster *kops.Cluster, region string) (map[st
clusterName := cluster.Name
switch cloud.ProviderID() {
case kops.CloudProviderAWS:
return aws.ListResourcesAWS(cloud.(awsup.AWSCloud), clusterName)
return aws.ListResourcesAWS(cloud.(awsup.AWSCloud), cluster)
case kops.CloudProviderDO:
return digitalocean.ListResources(cloud.(clouddo.DOCloud), clusterName)
case kops.CloudProviderGCE:
Expand Down

0 comments on commit 102237a

Please sign in to comment.