What happened:
The parseHostname function in the aws-sd provider splits hostnames at the first dot with no awareness of actual Cloud Map namespace boundaries. When a Cloud Map service name contains a dot (e.g., my-app.elb in namespace dev.local), the hostname my-app.elb.dev.local is incorrectly parsed as:
- service:
my-app
- namespace:
elb.dev.local
Instead of the correct:
- service:
my-app.elb
- namespace:
dev.local
matchingNamespaces then does an exact-match lookup and finds no namespace named elb.dev.local, so the record is silently dropped with:
Skipping record <hostname> because no namespace matching record DNS Name was detected
No --domain-filter workaround is possible because the issue is in hostname parsing, not namespace filtering.
This same root cause also affects SRV records (see #5714), where hostnames like _backend._tcp.backend.mynet.svc.internal are parsed with namespace _tcp.backend.mynet.svc.internal instead of mynet.svc.internal.
What you expected to happen:
parseHostname should use known Cloud Map namespace boundaries (longest-suffix matching) to correctly split the hostname, so that my-app.elb.dev.local with namespace dev.local yields service my-app.elb.
How to reproduce it (as minimally and precisely as possible):
- Create a Cloud Map namespace
dev.local (private DNS)
- Deploy external-dns with
--provider=aws-sd --domain-filter=dev.local
- Create a Kubernetes Ingress or Service with hostname
something.dotted.dev.local
- Observe external-dns logs:
level=warning msg="Skipping record something.dotted.dev.local 0 IN because no namespace matching record DNS Name was detected"
No Cloud Map service is created. A control test with a non-dotted hostname like simple.dev.local works correctly.
Anything else we need to know?:
The root cause is in provider/awssd/aws_sd.go, function parseHostname (~line 643):
func (p *AWSSDProvider) parseHostname(hostname string) (string, string) {
parts := strings.Split(hostname, ".")
return strings.Join(parts[1:], "."), parts[0]
}
This function has been unchanged since the aws-sd provider was created. The fix is to pass known namespaces into parseHostname and use longest-suffix matching, falling back to the original first-dot split for backward compatibility.
Also fixes #5714 (SRV records skipped with aws-sd).
Environment:
- External-DNS version: v0.15.1 through v0.21.0 (all current releases)
- DNS provider: aws-sd (AWS Cloud Map)
- Others: Tested on EKS with external-dns v0.20.0-eksbuild.5
Checklist
What happened:
The
parseHostnamefunction in the aws-sd provider splits hostnames at the first dot with no awareness of actual Cloud Map namespace boundaries. When a Cloud Map service name contains a dot (e.g.,my-app.elbin namespacedev.local), the hostnamemy-app.elb.dev.localis incorrectly parsed as:my-appelb.dev.localInstead of the correct:
my-app.elbdev.localmatchingNamespacesthen does an exact-match lookup and finds no namespace namedelb.dev.local, so the record is silently dropped with:No
--domain-filterworkaround is possible because the issue is in hostname parsing, not namespace filtering.This same root cause also affects SRV records (see #5714), where hostnames like
_backend._tcp.backend.mynet.svc.internalare parsed with namespace_tcp.backend.mynet.svc.internalinstead ofmynet.svc.internal.What you expected to happen:
parseHostnameshould use known Cloud Map namespace boundaries (longest-suffix matching) to correctly split the hostname, so thatmy-app.elb.dev.localwith namespacedev.localyields servicemy-app.elb.How to reproduce it (as minimally and precisely as possible):
dev.local(private DNS)--provider=aws-sd --domain-filter=dev.localsomething.dotted.dev.localNo Cloud Map service is created. A control test with a non-dotted hostname like
simple.dev.localworks correctly.Anything else we need to know?:
The root cause is in
provider/awssd/aws_sd.go, functionparseHostname(~line 643):This function has been unchanged since the aws-sd provider was created. The fix is to pass known namespaces into
parseHostnameand use longest-suffix matching, falling back to the original first-dot split for backward compatibility.Also fixes #5714 (SRV records skipped with aws-sd).
Environment:
Checklist
kubectl get <resource> -o yamloutput includingstatus