Skip to content

Commit

Permalink
cloudflare: Fix record updates due to empty zone ID (#262)
Browse files Browse the repository at this point in the history
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 <niryadav@redhat.com>
  • Loading branch information
black-dragon74 authored Jan 31, 2025
1 parent b178003 commit 22e6799
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/provider/cloudflare/cloudflare_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (provider *DNSProvider) Init(conf *settings.Settings) {
}

func (provider *DNSProvider) UpdateIP(domainName, subdomainName, ip string) error {
log.Infof("Checking IP for domain %s", domainName)
log.Infof("Checking IP for domain %s.%s", subdomainName, domainName)
zoneID := provider.getZone(domainName)
if zoneID != "" {
records := provider.getDNSRecords(zoneID)
Expand All @@ -88,6 +88,9 @@ func (provider *DNSProvider) UpdateIP(domainName, subdomainName, ip string) erro
if strings.Contains(rec.Name, subdomainName) || rec.Name == domainName {
if rec.IP != ip {
log.Infof("IP mismatch: Current(%+v) vs Cloudflare(%+v)", ip, rec.IP)
if rec.ZoneID == "" {
rec.ZoneID = zoneID
}
provider.updateRecord(rec, ip)
} else {
log.Infof("Record OK: %+v - %+v", rec.Name, rec.IP)
Expand Down

0 comments on commit 22e6799

Please sign in to comment.