Skip to content

Commit 22e6799

Browse files
cloudflare: Fix record updates due to empty zone ID (#262)
Cloudflare API in some cases returns an empty ZoneID for the zones endpoint. Due to that the subsequent update calls fail. This patch addresses this issue by manually specifying the zone ID in cases where it is empty. Signed-off-by: Niraj Yadav <[email protected]>
1 parent b178003 commit 22e6799

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/provider/cloudflare/cloudflare_handler.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (provider *DNSProvider) Init(conf *settings.Settings) {
7171
}
7272

7373
func (provider *DNSProvider) UpdateIP(domainName, subdomainName, ip string) error {
74-
log.Infof("Checking IP for domain %s", domainName)
74+
log.Infof("Checking IP for domain %s.%s", subdomainName, domainName)
7575
zoneID := provider.getZone(domainName)
7676
if zoneID != "" {
7777
records := provider.getDNSRecords(zoneID)
@@ -88,6 +88,9 @@ func (provider *DNSProvider) UpdateIP(domainName, subdomainName, ip string) erro
8888
if strings.Contains(rec.Name, subdomainName) || rec.Name == domainName {
8989
if rec.IP != ip {
9090
log.Infof("IP mismatch: Current(%+v) vs Cloudflare(%+v)", ip, rec.IP)
91+
if rec.ZoneID == "" {
92+
rec.ZoneID = zoneID
93+
}
9194
provider.updateRecord(rec, ip)
9295
} else {
9396
log.Infof("Record OK: %+v - %+v", rec.Name, rec.IP)

0 commit comments

Comments
 (0)