From 1fc97ec54a643ca09f3f892ed405362a749fc419 Mon Sep 17 00:00:00 2001 From: Andre Aguas Date: Mon, 4 Nov 2024 23:26:55 +0100 Subject: [PATCH] Add trailing dot to NS records in Google Cloud DNS NS records added in Google Cloud DNS must have a trailing dot. Otherwise the API throws the following error: ``` time="2024-11-04T10:34:20Z" level=error msg="googleapi: Error 400: Invalid value for 'entity.change.additions[cloud.k8gb.io.][NS].rrdata[0]': 'gslb-ns-eu-cloud.k8gb.io', invalid" ``` This is similar to CNAME, MX and SRV records. --- This change was tested with the a DNSEndpoint CRD containing the following endpoints: ``` endpoints: - dnsName: cloud.k8gb.io recordTTL: 5 recordType: NS targets: - gslb-ns-eu-cloud.k8gb.io - gslb-ns-us-cloud.k8gb.io - dnsName: gslb-ns-eu-cloud.k8gb.io ``` And the record was successfully created ``` gcloud dns record-sets list --zone="k8gb" --type=NS --name "cloud.k8gb.io." NAME TYPE TTL DATA cloud.k8gb.io. NS 5 gslb-ns-eu-cloud.k8gb.io.,gslb-ns-us-cloud.k8gb.io. ``` Signed-off-by: Andre Aguas --- provider/google/google.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/provider/google/google.go b/provider/google/google.go index 3502d6474..a3222ad59 100644 --- a/provider/google/google.go +++ b/provider/google/google.go @@ -445,6 +445,12 @@ func newRecord(ep *endpoint.Endpoint) *dns.ResourceRecordSet { } } + if ep.RecordType == endpoint.RecordTypeNS { + for i, nsRecord := range ep.Targets { + targets[i] = provider.EnsureTrailingDot(nsRecord) + } + } + // no annotation results in a Ttl of 0, default to 300 for backwards-compatibility var ttl int64 = googleRecordTTL if ep.RecordTTL.IsConfigured() {