Skip to content

Commit b226ea8

Browse files
authored
Merge pull request #4140 from tanujd11/fix/txt-record
fix: heritage txt record was not able to be created for txt record
2 parents d7f709f + f52cc1f commit b226ea8

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

registry/txt.go

-6
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,6 @@ func (im *TXTRegistry) Records(ctx context.Context) ([]*endpoint.Endpoint, error
212212
// generateTXTRecord generates both "old" and "new" TXT records.
213213
// Once we decide to drop old format we need to drop toTXTName() and rename toNewTXTName
214214
func (im *TXTRegistry) generateTXTRecord(r *endpoint.Endpoint) []*endpoint.Endpoint {
215-
// Missing TXT records are added to the set of changes.
216-
// Obviously, we don't need any other TXT record for them.
217-
if r.RecordType == endpoint.RecordTypeTXT {
218-
return nil
219-
}
220-
221215
endpoints := make([]*endpoint.Endpoint, 0)
222216

223217
if !im.txtEncryptEnabled && !im.mapper.recordTypeInAffix() && r.RecordType != endpoint.RecordTypeAAAA {

registry/txt_test.go

+17-1
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,8 @@ func testTXTRegistryMissingRecordsWithPrefix(t *testing.T) {
10461046
newEndpointWithOwner("txt.oldformat2.test-zone.example.org", "\"heritage=external-dns,external-dns/owner=owner\"", endpoint.RecordTypeTXT, ""),
10471047
newEndpointWithOwner("newformat.test-zone.example.org", "foobar.nameserver.com", endpoint.RecordTypeNS, ""),
10481048
newEndpointWithOwner("txt.ns-newformat.test-zone.example.org", "\"heritage=external-dns,external-dns/owner=owner\"", endpoint.RecordTypeTXT, ""),
1049+
newEndpointWithOwner("oldformat3.test-zone.example.org", "random", endpoint.RecordTypeTXT, ""),
1050+
newEndpointWithOwner("txt.oldformat3.test-zone.example.org", "\"heritage=external-dns,external-dns/owner=owner\"", endpoint.RecordTypeTXT, ""),
10491051
newEndpointWithOwner("txt.newformat.test-zone.example.org", "\"heritage=external-dns,external-dns/owner=owner\"", endpoint.RecordTypeTXT, ""),
10501052
newEndpointWithOwner("noheritage.test-zone.example.org", "random", endpoint.RecordTypeTXT, ""),
10511053
newEndpointWithOwner("oldformat-otherowner.test-zone.example.org", "bar.loadbalancer.com", endpoint.RecordTypeA, ""),
@@ -1084,6 +1086,20 @@ func testTXTRegistryMissingRecordsWithPrefix(t *testing.T) {
10841086
},
10851087
},
10861088
},
1089+
{
1090+
DNSName: "oldformat3.test-zone.example.org",
1091+
Targets: endpoint.Targets{"random"},
1092+
RecordType: endpoint.RecordTypeTXT,
1093+
Labels: map[string]string{
1094+
endpoint.OwnerLabelKey: "owner",
1095+
},
1096+
ProviderSpecific: []endpoint.ProviderSpecificProperty{
1097+
{
1098+
Name: "txt/force-update",
1099+
Value: "true",
1100+
},
1101+
},
1102+
},
10871103
{
10881104
DNSName: "newformat.test-zone.example.org",
10891105
Targets: endpoint.Targets{"foobar.nameserver.com"},
@@ -1122,7 +1138,7 @@ func testTXTRegistryMissingRecordsWithPrefix(t *testing.T) {
11221138
},
11231139
}
11241140

1125-
r, _ := NewTXTRegistry(p, "txt.", "", "owner", time.Hour, "wc", []string{endpoint.RecordTypeCNAME, endpoint.RecordTypeA, endpoint.RecordTypeNS}, []string{}, false, nil)
1141+
r, _ := NewTXTRegistry(p, "txt.", "", "owner", time.Hour, "wc", []string{endpoint.RecordTypeCNAME, endpoint.RecordTypeA, endpoint.RecordTypeNS, endpoint.RecordTypeTXT}, []string{}, false, nil)
11261142
records, _ := r.Records(ctx)
11271143

11281144
assert.True(t, testutils.SameEndpoints(records, expectedRecords))

0 commit comments

Comments
 (0)