Skip to content

Commit

Permalink
fix:On update failure, clear zoneID and recordIDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
bahonic authored and we11adam committed Jul 15, 2024
1 parent f524e73 commit ff66c67
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions updater/cloudflare/cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func (c *Cloudflare) updateDNSRecord(ctx context.Context, recordType, ip string)
_, err := c.client.UpdateDNSRecord(ctx, cloudflare.ZoneIdentifier(c.zoneID), updateParams)
if err != nil {
slog.Error("[CloudFlare] failed to update DNS record:", "error", err, "type", recordType)
delete(c.recordIDs, recordType)
return err
}
slog.Info("[CloudFlare] DNS record updated successfully", "type", recordType, "ip", ip)
Expand All @@ -133,6 +134,7 @@ func (c *Cloudflare) updateDNSRecord(ctx context.Context, recordType, ip string)
dnsRecords, _, err := c.client.ListDNSRecords(ctx, cloudflare.ZoneIdentifier(c.zoneID), params)
if err != nil {
slog.Error("[CloudFlare] failed to list DNS records:", "error", err, "type", recordType)
c.zoneID = ""
return err
}

Expand All @@ -151,6 +153,7 @@ func (c *Cloudflare) updateDNSRecord(ctx context.Context, recordType, ip string)
_, err := c.client.UpdateDNSRecord(ctx, cloudflare.ZoneIdentifier(c.zoneID), updateParams)
if err != nil {
slog.Error("[CloudFlare] failed to update DNS record:", "error", err, "type", recordType)
delete(c.recordIDs, recordType)
return err
}
slog.Info("[CloudFlare] DNS record updated successfully", "type", recordType, "ip", ip)
Expand Down

0 comments on commit ff66c67

Please sign in to comment.