tiredofit / docker-traefik-cloudflare-companion

Automatically Create CNAME records for containers served by Traefik
MIT License
404 stars 65 forks source link

No Cloudflare entries possible due to change in API #103

Closed StefanArts closed 4 months ago

StefanArts commented 5 months ago

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

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

Possible fixes

Change the ttl value to a number in the API request

tiredofit commented 5 months ago

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.

StefanArts commented 5 months ago

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)

kmdm commented 5 months ago

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

'ttl': int(os.environ.get("{}_TTL".format(k), DEFAULT_TTL)),
burnbrigther commented 5 months ago

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

morganzero commented 4 months ago

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

morganzero commented 4 months ago

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']),