diff --git a/source/crd.go b/source/crd.go index 3ffbb9bd09..b39dbaa9ab 100644 --- a/source/crd.go +++ b/source/crd.go @@ -121,6 +121,14 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error continue // no format constraint on targets case endpoint.RecordTypeCNAME: continue // RFC 1035 ยง5.1: trailing dot denotes an absolute FQDN in zone file notation; both forms are valid + case endpoint.RecordTypeSRV: + // SRV targets are " "; RFC 2782 + // requires the host to be an absolute FQDN and + // Endpoint.ValidateSRVRecord enforces the trailing dot. + // Reject-on-trailing-dot (the default branch below) would + // loop users between this warning and ValidateSRVRecord's + // "does not end with a dot" error (#6357). + continue } hasDot := strings.HasSuffix(target, ".") diff --git a/source/crd_test.go b/source/crd_test.go index 9e72f0eea1..65defb6659 100644 --- a/source/crd_test.go +++ b/source/crd_test.go @@ -320,6 +320,22 @@ func testCRDSourceEndpoints(t *testing.T) { }, expectEndpoints: true, }, + { + title: "SRV target with trailing dot (RFC 2782 absolute FQDN host) is valid (#6357)", + namespaceFilter: "foo", + objectNamespace: "foo", + labels: map[string]string{"test": "that"}, + labelSelector: labels.SelectorFromSet(labels.Set{"test": "that"}), + endpoints: []*endpoint.Endpoint{ + { + DNSName: "_svc._tcp.example.org", + Targets: endpoint.Targets{"0 0 80 abc.example.org.", "10 20 443 def.example.org."}, + RecordType: endpoint.RecordTypeSRV, + RecordTTL: 180, + }, + }, + expectEndpoints: true, + }, { title: "Create NAPTR record", namespaceFilter: "foo", @@ -549,6 +565,18 @@ func TestCRDSourceIllegalTargetWarnings(t *testing.T) { }, wantWarning: ``, }, + { + title: "SRV target with trailing dot produces no warning (#6357)", + endpoints: []*endpoint.Endpoint{ + { + DNSName: "_svc._tcp.example.org", + Targets: endpoint.Targets{"0 0 80 abc.example.org."}, + RecordType: endpoint.RecordTypeSRV, + RecordTTL: 180, + }, + }, + wantWarning: ``, + }, } { t.Run(ti.title, func(t *testing.T) { hook := logtest.LogsUnderTestWithLogLevel(log.WarnLevel, t)