tiredofit / docker-traefik-cloudflare-companion

Automatically Create CNAME records for containers served by Traefik

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No Cloudflare entries possible due to change in API

StefanArts opened this issue · comments

Summary

Cloudflare changed the API so that the ttl value has to be a number. This throws the following error when cloudflare companion tries to create a new dns entry:
...+0200 ERROR | ** service.example.com - 9022 TTL must be a number, not a string.

Steps to reproduce

  • Let Cloudflare Companion try to create a new dns entry

What is the expected correct behavior?

Cloudflare companion sends a successful API request and a new DNS entry gets created

Relevant logs and/or screenshots

Environment

  • Image version / tag: latest
  • Host OS: debian 12

Possible fixes

Change the ttl value to a number in the API request

Do you have any reference to the changed API? We should be pinned to using the old v4 API especially with a certain version of the cloudflare python module. I'd like to investigate more.

To be honest, I am not completely sure where the error occurs.
The only information I found regarding this is the following post:
https://community.cloudflare.com/t/error-9022-on-my-ddns/666726
I assumed this was the same problem, as the post is from a few days ago and I am using cloudflare-companion with the default value for ttl on a fresh setup.

API Reference for creating a zone specifies that the ttl value has to be a number:

ttl

Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. Value must be between 60 and 86400, with the minimum reduced to 30 for Enterprise zones.

(From https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-create-dns-record)

I would guess/venture that changing L100 to this would fix it:

'ttl': int(os.environ.get("{}_TTL".format(k), DEFAULT_TTL)),

watching this eagerly. I'm getting this as well.

Same here as well! 9022 TTL must be a number, not a string.

Do you have any reference to the changed API? We should be pinned to using the old v4 API especially with a certain version of the cloudflare python module. I'd like to investigate more.

Line 181 in install/usr/sbin/cloudflare-companion. Try changing: u'ttl': domain_info['ttl'], to u'ttl': int(domain_info['ttl']),