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

fix: set the default ttl to 60s #235

Merged
merged 5 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.22.7

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4 v4.3.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager v1.3.0
github.com/google/go-cmp v0.6.0
Expand All @@ -26,7 +27,6 @@ require go.goms.io/fleet v0.11.4

require (
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2 v2.2.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5 v5.7.0 // indirect
Expand Down
14 changes: 12 additions & 2 deletions pkg/controllers/hub/trafficmanagerprofile/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ const (
DNSRelativeNameFormat = "%s-%s"
// AzureResourceProfileNameFormat is the name format of the Azure Traffic Manager Profile created by the fleet controller.
AzureResourceProfileNameFormat = "fleet-%s"

// DefaultDNSTTL is in seconds. This informs the local DNS resolvers and DNS clients how long to cache DNS responses
// provided by this Traffic Manager profile.
// Defaults to 60 which is the same as the portal's default config.
DefaultDNSTTL = int64(60)
)

var (
Expand Down Expand Up @@ -170,8 +175,8 @@ func (r *Reconciler) handleUpdate(ctx context.Context, profile *fleetnetv1alpha1
// by ignoring others.
// The desired profile is built by the controllers and all the required fields should not be nil.
func EqualAzureTrafficManagerProfile(current, desired armtrafficmanager.Profile) bool {
// location and dnsConfig is not immutable
if current.Properties == nil || current.Properties.MonitorConfig == nil || current.Properties.ProfileStatus == nil || current.Properties.TrafficRoutingMethod == nil {
// location and dnsConfig (excluding TTL) is not immutable
zhiying-lin marked this conversation as resolved.
Show resolved Hide resolved
if current.Properties == nil || current.Properties.MonitorConfig == nil || current.Properties.ProfileStatus == nil || current.Properties.TrafficRoutingMethod == nil || current.Properties.DNSConfig == nil {
return false
}

Expand All @@ -194,6 +199,10 @@ func EqualAzureTrafficManagerProfile(current, desired armtrafficmanager.Profile)
return false
}

if current.Properties.DNSConfig.TTL == nil || *current.Properties.DNSConfig.TTL != *desired.Properties.DNSConfig.TTL {
zhiying-lin marked this conversation as resolved.
Show resolved Hide resolved
return false
}

if current.Tags == nil {
return false
}
Expand Down Expand Up @@ -271,6 +280,7 @@ func generateAzureTrafficManagerProfile(profile *fleetnetv1alpha1.TrafficManager
Properties: &armtrafficmanager.ProfileProperties{
DNSConfig: &armtrafficmanager.DNSConfig{
RelativeName: ptr.To(fmt.Sprintf(DNSRelativeNameFormat, profile.Namespace, profile.Name)),
TTL: ptr.To(DefaultDNSTTL), // no default value on the server side, using 60s same as portal's default config
zhiying-lin marked this conversation as resolved.
Show resolved Hide resolved
},
MonitorConfig: &armtrafficmanager.MonitorConfig{
IntervalInSeconds: mc.IntervalInSeconds,
Expand Down
Loading
Loading