Skip to content

Commit

Permalink
GH-545 restrict default geo to local
Browse files Browse the repository at this point in the history
  • Loading branch information
maksymvavilov committed Apr 16, 2024
1 parent e773993 commit 8b0f2ca
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions controllers/dns_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,8 @@ func (dh *dnsHelper) getLoadBalancedEndpoints(mcgTarget *multicluster.GatewayTar
ep = createOrUpdateEndpoint(lbName, []string{geoLbName}, kuadrantdnsv1alpha1.CNAMERecordType, string(geoCode), DefaultCnameTTL, currentEndpoints)

//Deal with the default geo endpoint first
if geoCode.IsDefaultCode() {
defaultEndpoint = ep
// continue here as we will add the `defaultEndpoint` later
continue
} else if (geoCode == mcgTarget.GetDefaultGeo()) || defaultEndpoint == nil {
// Ensure that a `defaultEndpoint` is always set, but the expected default takes precedence
if geoCode == mcgTarget.GetDefaultGeo() {
// Ensure that a `defaultEndpoint` is set only if geo of the current cluster is desired default geo
defaultEndpoint = createOrUpdateEndpoint(lbName, []string{geoLbName}, kuadrantdnsv1alpha1.CNAMERecordType, "default", DefaultCnameTTL, currentEndpoints)
}

Expand All @@ -267,9 +263,12 @@ func (dh *dnsHelper) getLoadBalancedEndpoints(mcgTarget *multicluster.GatewayTar
}

if len(endpoints) > 0 {
// Add the `defaultEndpoint`, this should always be set by this point if `endpoints` isn't empty
defaultEndpoint.SetProviderSpecificProperty(kuadrantdnsv1alpha1.ProviderSpecificGeoCode, string(v1alpha1.WildcardGeo))
endpoints = append(endpoints, defaultEndpoint)

// Add the `defaultEndpoint`, this should be set only if current cluster geo is the desired default geo
if defaultEndpoint != nil {
defaultEndpoint.SetProviderSpecificProperty(kuadrantdnsv1alpha1.ProviderSpecificGeoCode, string(v1alpha1.WildcardGeo))
endpoints = append(endpoints, defaultEndpoint)
}
//Create gwListenerHost CNAME (shop.example.com -> lb-a1b2.shop.example.com)
ep = createOrUpdateEndpoint(hostname, []string{lbName}, kuadrantdnsv1alpha1.CNAMERecordType, "", DefaultCnameTTL, currentEndpoints)
endpoints = append(endpoints, ep)
Expand Down

0 comments on commit 8b0f2ca

Please sign in to comment.