Skip to content

Commit ef7b98a

Browse files
committed
refactor(aws): simplify adjustOtherRecord with clarifying comment
Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
1 parent 9bb249b commit ef7b98a

File tree

2 files changed

+7
-79
lines changed

2 files changed

+7
-79
lines changed

provider/aws/aws.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -898,22 +898,13 @@ func (p *AWSProvider) adjustCNAMERecord(ep *endpoint.Endpoint) {
898898
}
899899
}
900900

901-
// See: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values-alias.html
902901
func (p *AWSProvider) adjustOtherRecord(ep *endpoint.Endpoint) {
903-
// NS and SOA records do not support alias
904-
if ep.RecordType == endpoint.RecordTypeNS || ep.RecordType == "SOA" {
905-
ep.DeleteProviderSpecificProperty(providerSpecificAlias)
906-
ep.DeleteProviderSpecificProperty(providerSpecificEvaluateTargetHealth)
907-
return
908-
}
909-
// All other record types support alias when pointing to another record in the same hosted zone
910-
isAlias, _ := ep.GetBoolProviderSpecificProperty(providerSpecificAlias)
911-
if isAlias {
912-
p.adjustAliasRecord(ep)
913-
} else {
914-
ep.DeleteProviderSpecificProperty(providerSpecificAlias)
915-
ep.DeleteProviderSpecificProperty(providerSpecificEvaluateTargetHealth)
916-
}
902+
// Although Route53 supports alias records for all types except NS and SOA
903+
// (see: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values-alias.html),
904+
// ExternalDNS only uses alias for A/AAAA records converted from CNAME.
905+
// For other record types, we simply remove the alias-related properties.
906+
ep.DeleteProviderSpecificProperty(providerSpecificAlias)
907+
ep.DeleteProviderSpecificProperty(providerSpecificEvaluateTargetHealth)
917908
}
918909

919910
// if the endpoint is using geoproximity, set the bias to 0 if not set

provider/aws/aws_test.go

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3324,7 +3324,7 @@ func TestAWSProvider_adjustEndpointAndNewAaaaIfNeeded(t *testing.T) {
33243324
expectedAaaa: nil,
33253325
},
33263326
{
3327-
name: "MX record with alias=true should be treated as alias and not create AAAA",
3327+
name: "MX record with alias-related properties should drop them, keep ttl and not create AAAA",
33283328
ep: &endpoint.Endpoint{
33293329
DNSName: "test.foo.bar.",
33303330
RecordType: endpoint.RecordTypeMX,
@@ -3341,42 +3341,6 @@ func TestAWSProvider_adjustEndpointAndNewAaaaIfNeeded(t *testing.T) {
33413341
},
33423342
},
33433343
},
3344-
expected: &endpoint.Endpoint{
3345-
DNSName: "test.foo.bar.",
3346-
RecordType: endpoint.RecordTypeMX,
3347-
Targets: endpoint.Targets{"10 mail.example.com."},
3348-
RecordTTL: 300,
3349-
ProviderSpecific: endpoint.ProviderSpecific{
3350-
{
3351-
Name: providerSpecificAlias,
3352-
Value: "true",
3353-
},
3354-
{
3355-
Name: providerSpecificEvaluateTargetHealth,
3356-
Value: "true",
3357-
},
3358-
},
3359-
},
3360-
expectedAaaa: nil,
3361-
},
3362-
{
3363-
name: "MX record with alias=false should drop alias properties and not create AAAA",
3364-
ep: &endpoint.Endpoint{
3365-
DNSName: "test.foo.bar.",
3366-
RecordType: endpoint.RecordTypeMX,
3367-
Targets: endpoint.Targets{"10 mail.example.com."},
3368-
RecordTTL: 600,
3369-
ProviderSpecific: endpoint.ProviderSpecific{
3370-
{
3371-
Name: providerSpecificAlias,
3372-
Value: "false",
3373-
},
3374-
{
3375-
Name: providerSpecificEvaluateTargetHealth,
3376-
Value: "true",
3377-
},
3378-
},
3379-
},
33803344
expected: &endpoint.Endpoint{
33813345
DNSName: "test.foo.bar.",
33823346
RecordType: endpoint.RecordTypeMX,
@@ -3386,33 +3350,6 @@ func TestAWSProvider_adjustEndpointAndNewAaaaIfNeeded(t *testing.T) {
33863350
},
33873351
expectedAaaa: nil,
33883352
},
3389-
3390-
// --- NS records ---
3391-
{
3392-
name: "NS record with alias=true should drop alias properties since NS does not support alias",
3393-
ep: &endpoint.Endpoint{
3394-
DNSName: "test.foo.bar.",
3395-
RecordType: endpoint.RecordTypeNS,
3396-
Targets: endpoint.Targets{"ns1.example.com."},
3397-
ProviderSpecific: endpoint.ProviderSpecific{
3398-
{
3399-
Name: providerSpecificAlias,
3400-
Value: "true",
3401-
},
3402-
{
3403-
Name: providerSpecificEvaluateTargetHealth,
3404-
Value: "true",
3405-
},
3406-
},
3407-
},
3408-
expected: &endpoint.Endpoint{
3409-
DNSName: "test.foo.bar.",
3410-
RecordType: endpoint.RecordTypeNS,
3411-
Targets: endpoint.Targets{"ns1.example.com."},
3412-
ProviderSpecific: endpoint.ProviderSpecific{},
3413-
},
3414-
expectedAaaa: nil,
3415-
},
34163353
}
34173354

34183355
for _, tt := range tests {

0 commit comments

Comments
 (0)