Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws: Skip Route53 cleanup for clusters without DNS #14707

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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