octodns / octodns-cloudflare

Cloudflare DNS provider for octoDNS
MIT License
24 stars 18 forks source link

Unable to update CloudFlare records #9

Closed ad-m closed 2 years ago

ad-m commented 6 years ago

Hello,

I dumped zone, fixed TTL (detected TTL is 1, so I set 7200). Then I got the following error messages:

$ octodns-sync --config-file=./env/production.yaml zajezyk.pl. --doit
2018-02-18T19:39:31  [140516258113280] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-18T19:39:31  [140516258113280] INFO  Manager __init__:   max_workers=1
2018-02-18T19:39:31  [140516258113280] INFO  Manager __init__:   max_workers=False
2018-02-18T19:39:31  [140516258113280] INFO  Manager sync: eligible_zones=['zajezyk.pl.'], eligible_targets=[], dry_run=False, force=False
2018-02-18T19:39:31  [140516258113280] INFO  Manager sync:   zone=zajezyk.pl.
2018-02-18T19:39:31  [140516258113280] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-18T19:39:31  [140516258113280] INFO  YamlProvider[config] populate:   found 6 records
2018-02-18T19:39:31  [140516258113280] INFO  CloudflareProvider[cloudflare_shared] plan: desired=zajezyk.pl.
2018-02-18T19:39:32  [140516258113280] INFO  CloudflareProvider[cloudflare_shared] populate:   found 6 records
2018-02-18T19:39:32  [140516258113280] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=6, Deletes=0, Existing Records=6
2018-02-18T19:39:32  [140516258113280] INFO  Manager 
********************************************************************************
* zajezyk.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <TxtRecord TXT 1, x._domainkey.zajezyk.pl., ['v=DKIM1\; k=rsa\; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAomyrwWA5VA6NlUFafVCBKYOanaZesoWMsIxk4QALoSw3bUUwIf8tRMxetOi9gBxqScXwjdqz5mu8+qtZrdGeh1UdvIFCX3r/dC7GYzK7uiNGi2bIRrjsrssLmHzlnNuI3IZ9G2PSrYcYqrkCX4TQhE0rj5hI2zNVW06RoTiJMqRh29GoKS07InYjaQXiND7Nief8MoJD1cGmGky6sHvsO1kwL1KbGfqXbw2bawpm0jUQUVCjBGm/kuteq2GlirooVeKI3OsC8NjW8mOuAKy+ECGajo59HNoI2gM4hNpbegSjm/DS5TnJoarSpk4a66bmWDBayoEmjHFWUFBZsKac9QIDAQAB']> ->
*     <TxtRecord TXT 7200, x._domainkey.zajezyk.pl., ['v=DKIM1\; k=rsa\; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAomyrwWA5VA6NlUFafVCBKYOanaZesoWMsIxk4QALoSw3bUUwIf8tRMxetOi9gBxqScXwjdqz5mu8+qtZrdGeh1UdvIFCX3r/dC7GYzK7uiNGi2bIRrjsrssLmHzlnNuI3IZ9G2PSrYcYqrkCX4TQhE0rj5hI2zNVW06RoTiJMqRh29GoKS07InYjaQXiND7Nief8MoJD1cGmGky6sHvsO1kwL1KbGfqXbw2bawpm0jUQUVCjBGm/kuteq2GlirooVeKI3OsC8NjW8mOuAKy+ECGajo59HNoI2gM4hNpbegSjm/DS5TnJoarSpk4a66bmWDBayoEmjHFWUFBZsKac9QIDAQAB']> (config)
*   Update
*     <TxtRecord TXT 1, _domainkey.zajezyk.pl., ['o=~']> ->
*     <TxtRecord TXT 7200, _domainkey.zajezyk.pl., ['o=~']> (config)
*   Update
*     <ARecord A 1, zajezyk.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, zajezyk.pl., ['185.23.21.15']> (config)
*   Update
*     <ARecord A 1, www.zajezyk.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, www.zajezyk.pl., ['185.23.21.15']> (config)
*   Update
*     <TxtRecord TXT 1, zajezyk.pl., ['v=spf1 a mx include:_spf.zenbox.pl -all']> ->
*     <TxtRecord TXT 7200, zajezyk.pl., ['v=spf1 a mx include:_spf.zenbox.pl -all']> (config)
*   Update
*     <TxtRecord TXT 1, _dmarc.zajezyk.pl., ['v=DMARC1\; p=none\; sp=none\; rua=mailto:abuse@zenbox.pl']> ->
*     <TxtRecord TXT 7200, _dmarc.zajezyk.pl., ['v=DMARC1\; p=none\; sp=none\; rua=mailto:abuse@zenbox.pl']> (config)
*   Summary: Creates=0, Updates=6, Deletes=0, Existing Records=6
********************************************************************************

2018-02-18T19:39:32  [140516258113280] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
Traceback (most recent call last):
  File "/home/adas/.virtualenvs/infra/bin/octodns-sync", line 11, in <module>
    sys.exit(main())
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/cmds/sync.py", line 39, in main
    dry_run=not args.doit, force=args.force)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/manager.py", line 313, in sync
    total_changes += target.apply(plan)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/base.py", line 157, in apply
    self._apply(plan)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 285, in _apply
    getattr(self, '_apply_{}'.format(class_name))(change)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 252, in _apply_Update
    self._apply_Create(change)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 248, in _apply_Create
    self._request('POST', path, data=content)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 68, in _request
    resp.raise_for_status()
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/requests/models.py", line 935, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.cloudflare.com/client/v4/zones/e63fd9e266f8b6ba6f227901ee7294fc/dns_records

For debug purpuses I added

        if resp.status_code != 200:
            import pdb; pdb.set_trace()

in cloudflare.py in 68-69 lines.

Next to I got following result:

$ octodns-sync --config-file=./env/production.yaml zajezyk.pl. --doit
2018-02-18T19:41:06  [140449092114176] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-18T19:41:06  [140449092114176] INFO  Manager __init__:   max_workers=1
2018-02-18T19:41:06  [140449092114176] INFO  Manager __init__:   max_workers=False
2018-02-18T19:41:06  [140449092114176] INFO  Manager sync: eligible_zones=['zajezyk.pl.'], eligible_targets=[], dry_run=False, force=False
2018-02-18T19:41:06  [140449092114176] INFO  Manager sync:   zone=zajezyk.pl.
2018-02-18T19:41:06  [140449092114176] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-18T19:41:06  [140449092114176] INFO  YamlProvider[config] populate:   found 6 records
2018-02-18T19:41:06  [140449092114176] INFO  CloudflareProvider[cloudflare_shared] plan: desired=zajezyk.pl.
2018-02-18T19:41:08  [140449092114176] INFO  CloudflareProvider[cloudflare_shared] populate:   found 6 records
2018-02-18T19:41:08  [140449092114176] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=6, Deletes=0, Existing Records=6
2018-02-18T19:41:08  [140449092114176] INFO  Manager 
********************************************************************************
* zajezyk.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <TxtRecord TXT 1, x._domainkey.zajezyk.pl., ['v=DKIM1\; k=rsa\; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAomyrwWA5VA6NlUFafVCBKYOanaZesoWMsIxk4QALoSw3bUUwIf8tRMxetOi9gBxqScXwjdqz5mu8+qtZrdGeh1UdvIFCX3r/dC7GYzK7uiNGi2bIRrjsrssLmHzlnNuI3IZ9G2PSrYcYqrkCX4TQhE0rj5hI2zNVW06RoTiJMqRh29GoKS07InYjaQXiND7Nief8MoJD1cGmGky6sHvsO1kwL1KbGfqXbw2bawpm0jUQUVCjBGm/kuteq2GlirooVeKI3OsC8NjW8mOuAKy+ECGajo59HNoI2gM4hNpbegSjm/DS5TnJoarSpk4a66bmWDBayoEmjHFWUFBZsKac9QIDAQAB']> ->
*     <TxtRecord TXT 7200, x._domainkey.zajezyk.pl., ['v=DKIM1\; k=rsa\; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAomyrwWA5VA6NlUFafVCBKYOanaZesoWMsIxk4QALoSw3bUUwIf8tRMxetOi9gBxqScXwjdqz5mu8+qtZrdGeh1UdvIFCX3r/dC7GYzK7uiNGi2bIRrjsrssLmHzlnNuI3IZ9G2PSrYcYqrkCX4TQhE0rj5hI2zNVW06RoTiJMqRh29GoKS07InYjaQXiND7Nief8MoJD1cGmGky6sHvsO1kwL1KbGfqXbw2bawpm0jUQUVCjBGm/kuteq2GlirooVeKI3OsC8NjW8mOuAKy+ECGajo59HNoI2gM4hNpbegSjm/DS5TnJoarSpk4a66bmWDBayoEmjHFWUFBZsKac9QIDAQAB']> (config)
*   Update
*     <TxtRecord TXT 1, _domainkey.zajezyk.pl., ['o=~']> ->
*     <TxtRecord TXT 7200, _domainkey.zajezyk.pl., ['o=~']> (config)
*   Update
*     <ARecord A 1, zajezyk.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, zajezyk.pl., ['185.23.21.15']> (config)
*   Update
*     <ARecord A 1, www.zajezyk.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, www.zajezyk.pl., ['185.23.21.15']> (config)
*   Update
*     <TxtRecord TXT 1, zajezyk.pl., ['v=spf1 a mx include:_spf.zenbox.pl -all']> ->
*     <TxtRecord TXT 7200, zajezyk.pl., ['v=spf1 a mx include:_spf.zenbox.pl -all']> (config)
*   Update
*     <TxtRecord TXT 1, _dmarc.zajezyk.pl., ['v=DMARC1\; p=none\; sp=none\; rua=mailto:abuse@zenbox.pl']> ->
*     <TxtRecord TXT 7200, _dmarc.zajezyk.pl., ['v=DMARC1\; p=none\; sp=none\; rua=mailto:abuse@zenbox.pl']> (config)
*   Summary: Creates=0, Updates=6, Deletes=0, Existing Records=6
********************************************************************************

2018-02-18T19:41:08  [140449092114176] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
> /home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py(70)_request()
-> resp.raise_for_status()
(Pdb) print(resp)
<Response [400]>
(Pdb) resp.status_code
400
(Pdb) resp.json()
{u'errors': [{u'message': u'The record already exists.', u'code': 81057}], u'messages': [], u'result': None, u'success': False}
ross commented 6 years ago

Hrm. I've not seen the TTL=1 thing in Cloudflare before. In general they have a minimum of 120s in my testing. Are these records Cloudflare "protected"? Maybe the TTL comes back when that's the case. @vanbroup did some recent work (in master now) around the proxied/protected records. If these are protected records that there's likely issues with trying to update them with out all the protected info from the API. That's not something generally supported by octoDNS atm.

vanbroup commented 6 years ago

@ross the TTL from Cloudflare is always saved as 1 (it's the Cloudflare default which actually means auto) but ignored in changes when you set it to lower than 120. In this case, @ad-m has changed the TTL to 7200 which is causing an update to Cloudflare. It would actually be great if we could set a minimal TTL or reference TTL for exports. I'm currently using simple sed replace, but I'm only exporting records from Cloudflare. TTL 1 actually means let Cloudflare decide for the best TTL for your record as currently will set a TTL of 1 at other DNS providers, probably not the desired configuration value.

@ad-m from the changes I can't see what is causing this The record already exists error. As we have 6 of 6 records I suppose these are all records in your zone? Can you confirm if Cloudflare is enabled for one of these records as Cloudflare might decide to ignore the TTL value when it's and return an error as that would make there are no actual changes? Maybe you can also check if you can only change the TTL of a TXT record, if that works you can change one more in each run to see which one is causing the problem.

vanbroup commented 6 years ago

@ad-m have been doing some tests but not been able to replicate this specific problem, maybe you can share your zone yaml file?

vanbroup commented 6 years ago

@ross setting back the TTL from > 120 to 1 (automatic) will enforce the 120 value, so you are currently not able to get back to the defaults.

Updates also disable the proxied status by default.

ross commented 6 years ago

Updates also disable the proxied status by default.

Yeah. In general Cloudflare's proxy setup isn't really supported. I wouldn't recommend using octoDNS with CF if you're using proxied records. I don't use CF for anything currently and won't have time to dig in and find a viable path, but definitely would be happy to see things in a workable state.

Should the cdn argument from https://github.com/github/octodns/pull/182 be turned on to ignore all these records? Tbh I'm completely lost when that stuff is enabled in CF b/c I've never turned it on and it wasn't part of the use case I envisioned back when I wrote the original provider.

ross commented 6 years ago

Automatic TTL proposed handling in https://github.com/github/octodns/pull/210.

ad-m commented 6 years ago

I updated the program using versions from the repository. Everything works successfully.

ad-m commented 6 years ago

I found this issue again.

$ octodns-sync --config-file=./env/production.yaml --doit watchdogportal.pl. --force
2018-02-25T19:19:17  [140389037709056] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-25T19:19:17  [140389037709056] INFO  Manager __init__:   max_workers=1
2018-02-25T19:19:17  [140389037709056] INFO  Manager __init__:   max_workers=False
2018-02-25T19:19:17  [140389037709056] INFO  Manager sync: eligible_zones=['watchdogportal.pl.'], eligible_targets=[], dry_run=False, force=True
2018-02-25T19:19:17  [140389037709056] INFO  Manager sync:   zone=watchdogportal.pl.
2018-02-25T19:19:17  [140389037709056] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-25T19:19:17  [140389037709056] INFO  YamlProvider[config] populate:   found 10 records
2018-02-25T19:19:17  [140389037709056] INFO  CloudflareProvider[cloudflare_shared] plan: desired=watchdogportal.pl.
2018-02-25T19:19:18  [140389037709056] INFO  CloudflareProvider[cloudflare_shared] populate:   found 10 records
2018-02-25T19:19:18  [140389037709056] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=10, Deletes=0, Existing Records=10
2018-02-25T19:19:18  [140389037709056] INFO  Manager 
********************************************************************************
* watchdogportal.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <ARecord A 1, kursy.watchdogportal.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, kursy.watchdogportal.pl., ['185.23.21.15']> (config)
*   Update
*     <ARecord A 1, archiwum.watchdogportal.pl., ['31.6.70.229']> ->
*     <ARecord A 7200, archiwum.watchdogportal.pl., ['31.6.70.229']> (config)
*   Update
*     <CnameRecord CNAME 1, mail.watchdogportal.pl., joanna.jawne.info.pl.> ->
*     <CnameRecord CNAME 7200, mail.watchdogportal.pl., joanna.jawne.info.pl.> (config)
*   Update
*     <MxRecord MX 1, kursy.watchdogportal.pl., [''10 mx1.zenbox.pl.'', ''20 mx2.zenbox.pl.'', ''30 mx3.zenbox.pl.'']> ->
*     <MxRecord MX 7200, kursy.watchdogportal.pl., [''10 mx1.zenbox.pl.'', ''20 mx2.zenbox.pl.'', ''30 mx3.zenbox.pl.'']> (config)
*   Update
*     <ARecord A 1, watchdogportal.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, watchdogportal.pl., ['185.23.21.15']> (config)
*   Update
*     <CnameRecord CNAME 1, www.kursy.watchdogportal.pl., laura.jawne.info.pl.> ->
*     <CnameRecord CNAME 7200, www.kursy.watchdogportal.pl., laura.jawne.info.pl.> (config)
*   Update
*     <ARecord A 1, www.watchdogportal.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, www.watchdogportal.pl., ['185.23.21.15']> (config)
*   Update
*     <CnameRecord CNAME 1, emaillabs._domainkey.watchdogportal.pl., emaillabs._domainkey.emaillabs.net.pl.> ->
*     <CnameRecord CNAME 7200, emaillabs._domainkey.watchdogportal.pl., emaillabs._domainkey.emaillabs.net.pl.> (config)
*   Update
*     <TxtRecord TXT 1, watchdogportal.pl., ['google-site-verification=g8uMdo5MzUDqNJ6qObquyGwJrL8vU7by_ahgpX9yjes', 'v=spf1 include:_spf.emaillabs.net.pl ~all']> ->
*     <TxtRecord TXT 7200, watchdogportal.pl., ['google-site-verification=g8uMdo5MzUDqNJ6qObquyGwJrL8vU7by_ahgpX9yjes', 'v=spf1 include:_spf.emaillabs.net.pl ~all']> (config)
*   Update
*     <MxRecord MX 1, watchdogportal.pl., [''10 joanna.jawne.info.pl.'']> ->
*     <MxRecord MX 7200, watchdogportal.pl., [''10 joanna.jawne.info.pl.'']> (config)
*   Summary: Creates=0, Updates=10, Deletes=0, Existing Records=10
********************************************************************************

2018-02-25T19:19:18  [140389037709056] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
Traceback (most recent call last):
  File "/home/adas/.virtualenvs/infra/bin/octodns-sync", line 11, in <module>
    load_entry_point('octodns==0.8.8', 'console_scripts', 'octodns-sync')()
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/cmds/sync.py", line 39, in main
    dry_run=not args.doit, force=args.force)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/manager.py", line 311, in sync
    total_changes += target.apply(plan)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/base.py", line 87, in apply
    self._apply(plan)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 458, in _apply
    getattr(self, '_apply_{}'.format(class_name))(change)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 416, in _apply_Update
    self._request('PUT', path, data=add_content)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 80, in _request
    raise CloudflareError(resp.json())
octodns.provider.cloudflare.CloudflareError: A record with those settings already exists.

Here is YAML file:

---
? ''
: - ttl: 7200
    type: A
    value: 185.23.21.15
  - ttl: 7200
    type: MX
    value:
      exchange: joanna.jawne.info.pl.
      preference: 10
  - ttl: 7200
    type: TXT
    values:
    - google-site-verification=g8uMdo5MzUDqNJ6qObquyGwJrL8vU7by_ahgpX9yjes
    - v=spf1 include:_spf.emaillabs.net.pl ~all
archiwum:
  ttl: 7200
  type: A
  value: 31.6.70.229
emaillabs._domainkey:
  ttl: 7200
  type: CNAME
  value: emaillabs._domainkey.emaillabs.net.pl.
kursy:
- ttl: 7200
  type: A
  value: 185.23.21.15
- ttl: 7200
  type: MX
  values:
  - exchange: mx1.zenbox.pl.
    preference: 10
  - exchange: mx2.zenbox.pl.
    preference: 20
  - exchange: mx3.zenbox.pl.
    preference: 30
mail:
  ttl: 7200
  type: CNAME
  value: joanna.jawne.info.pl.
www:
  ttl: 7200
  type: A
  value: 185.23.21.15
www.kursy:
  ttl: 7200
  type: CNAME
  value: laura.jawne.info.pl.

Here is CloudFlare settings: zaznaczenie_1362


Edit: Some changes was made. Next try:

$ octodns-sync --config-file=./env/production.yaml --doit watchdogportal.pl. --force
2018-02-25T19:25:35  [139891233019648] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-25T19:25:35  [139891233019648] INFO  Manager __init__:   max_workers=1
2018-02-25T19:25:35  [139891233019648] INFO  Manager __init__:   max_workers=False
2018-02-25T19:25:35  [139891233019648] INFO  Manager sync: eligible_zones=['watchdogportal.pl.'], eligible_targets=[], dry_run=False, force=True
2018-02-25T19:25:35  [139891233019648] INFO  Manager sync:   zone=watchdogportal.pl.
2018-02-25T19:25:35  [139891233019648] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-25T19:25:35  [139891233019648] INFO  YamlProvider[config] populate:   found 10 records
2018-02-25T19:25:35  [139891233019648] INFO  CloudflareProvider[cloudflare_shared] plan: desired=watchdogportal.pl.
2018-02-25T19:25:37  [139891233019648] INFO  CloudflareProvider[cloudflare_shared] populate:   found 10 records
2018-02-25T19:25:37  [139891233019648] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=7, Deletes=0, Existing Records=10
2018-02-25T19:25:37  [139891233019648] INFO  Manager 
********************************************************************************
* watchdogportal.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <MxRecord MX 1, kursy.watchdogportal.pl., [''10 mx1.zenbox.pl.'', ''20 mx2.zenbox.pl.'', ''30 mx3.zenbox.pl.'']> ->
*     <MxRecord MX 7200, kursy.watchdogportal.pl., [''10 mx1.zenbox.pl.'', ''20 mx2.zenbox.pl.'', ''30 mx3.zenbox.pl.'']> (config)
*   Update
*     <ARecord A 1, watchdogportal.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, watchdogportal.pl., ['185.23.21.15']> (config)
*   Update
*     <CnameRecord CNAME 1, www.kursy.watchdogportal.pl., laura.jawne.info.pl.> ->
*     <CnameRecord CNAME 7200, www.kursy.watchdogportal.pl., laura.jawne.info.pl.> (config)
*   Update
*     <ARecord A 1, www.watchdogportal.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, www.watchdogportal.pl., ['185.23.21.15']> (config)
*   Update
*     <CnameRecord CNAME 1, emaillabs._domainkey.watchdogportal.pl., emaillabs._domainkey.emaillabs.net.pl.> ->
*     <CnameRecord CNAME 7200, emaillabs._domainkey.watchdogportal.pl., emaillabs._domainkey.emaillabs.net.pl.> (config)
*   Update
*     <TxtRecord TXT 1, watchdogportal.pl., ['google-site-verification=g8uMdo5MzUDqNJ6qObquyGwJrL8vU7by_ahgpX9yjes', 'v=spf1 include:_spf.emaillabs.net.pl ~all']> ->
*     <TxtRecord TXT 7200, watchdogportal.pl., ['google-site-verification=g8uMdo5MzUDqNJ6qObquyGwJrL8vU7by_ahgpX9yjes', 'v=spf1 include:_spf.emaillabs.net.pl ~all']> (config)
*   Update
*     <MxRecord MX 1, watchdogportal.pl., [''10 joanna.jawne.info.pl.'']> ->
*     <MxRecord MX 7200, watchdogportal.pl., [''10 joanna.jawne.info.pl.'']> (config)
*   Summary: Creates=0, Updates=7, Deletes=0, Existing Records=10
********************************************************************************

2018-02-25T19:25:37  [139891233019648] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
Traceback (most recent call last):
  File "/home/adas/.virtualenvs/infra/bin/octodns-sync", line 11, in <module>
    load_entry_point('octodns==0.8.8', 'console_scripts', 'octodns-sync')()
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/cmds/sync.py", line 39, in main
    dry_run=not args.doit, force=args.force)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/manager.py", line 311, in sync
    total_changes += target.apply(plan)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/base.py", line 87, in apply
    self._apply(plan)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 458, in _apply
    getattr(self, '_apply_{}'.format(class_name))(change)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 416, in _apply_Update
    self._request('PUT', path, data=add_content)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 80, in _request
    raise CloudflareError(resp.json())
octodns.provider.cloudflare.CloudflareError: A record with those settings already exists.

On retry there is no more changes on CloudFlare.

Edit:

On changes all TTL in zone there is following changes:

$ octodns-sync --config-file=./env/production.yaml --doit watchdogportal.pl. --force
2018-02-25T19:28:48  [139856222881536] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-25T19:28:48  [139856222881536] INFO  Manager __init__:   max_workers=1
2018-02-25T19:28:48  [139856222881536] INFO  Manager __init__:   max_workers=False
2018-02-25T19:28:48  [139856222881536] INFO  Manager sync: eligible_zones=['watchdogportal.pl.'], eligible_targets=[], dry_run=False, force=True
2018-02-25T19:28:48  [139856222881536] INFO  Manager sync:   zone=watchdogportal.pl.
2018-02-25T19:28:48  [139856222881536] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-25T19:28:48  [139856222881536] INFO  YamlProvider[config] populate:   found 10 records
2018-02-25T19:28:48  [139856222881536] INFO  CloudflareProvider[cloudflare_shared] plan: desired=watchdogportal.pl.
2018-02-25T19:28:50  [139856222881536] INFO  CloudflareProvider[cloudflare_shared] populate:   found 10 records
2018-02-25T19:28:50  [139856222881536] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=3, Deletes=0, Existing Records=10
2018-02-25T19:28:50  [139856222881536] INFO  Manager 
********************************************************************************
* watchdogportal.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <ARecord A 7200, kursy.watchdogportal.pl., ['185.23.21.15']> ->
*     <ARecord A 1, kursy.watchdogportal.pl., ['185.23.21.15']> (config)
*   Update
*     <ARecord A 7200, archiwum.watchdogportal.pl., ['31.6.70.229']> ->
*     <ARecord A 1, archiwum.watchdogportal.pl., ['31.6.70.229']> (config)
*   Update
*     <CnameRecord CNAME 7200, mail.watchdogportal.pl., joanna.jawne.info.pl.> ->
*     <CnameRecord CNAME 1, mail.watchdogportal.pl., joanna.jawne.info.pl.> (config)
*   Summary: Creates=0, Updates=3, Deletes=0, Existing Records=10
********************************************************************************

2018-02-25T19:28:50  [139856222881536] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
2018-02-25T19:28:52  [139856222881536] INFO  Manager sync:   3 total changes

On changes in YAML to first record:

$ octodns-sync --config-file=./env/production.yaml --doit watchdogportal.pl. --force
2018-02-25T19:30:08  [139726848423680] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-25T19:30:08  [139726848423680] INFO  Manager __init__:   max_workers=1
2018-02-25T19:30:08  [139726848423680] INFO  Manager __init__:   max_workers=False
2018-02-25T19:30:08  [139726848423680] INFO  Manager sync: eligible_zones=['watchdogportal.pl.'], eligible_targets=[], dry_run=False, force=True
2018-02-25T19:30:08  [139726848423680] INFO  Manager sync:   zone=watchdogportal.pl.
2018-02-25T19:30:08  [139726848423680] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-25T19:30:08  [139726848423680] INFO  YamlProvider[config] populate:   found 10 records
2018-02-25T19:30:08  [139726848423680] INFO  CloudflareProvider[cloudflare_shared] plan: desired=watchdogportal.pl.
2018-02-25T19:30:10  [139726848423680] INFO  CloudflareProvider[cloudflare_shared] populate:   found 10 records
2018-02-25T19:30:10  [139726848423680] INFO  CloudflareProvider[cloudflare_shared] plan:   filtered out 3 changes
2018-02-25T19:30:10  [139726848423680] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=1, Deletes=0, Existing Records=10
2018-02-25T19:30:10  [139726848423680] INFO  Manager 
********************************************************************************
* watchdogportal.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <ARecord A 1, watchdogportal.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, watchdogportal.pl., ['185.23.21.15']> (config)
*   Summary: Creates=0, Updates=1, Deletes=0, Existing Records=10
********************************************************************************

2018-02-25T19:30:10  [139726848423680] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
2018-02-25T19:30:10  [139726848423680] INFO  Manager sync:   1 total changes

On changes TTL on second record:

$ octodns-sync --config-file=./env/production.yaml --doit watchdogportal.pl. --force
2018-02-25T19:30:49  [140700151060224] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-25T19:30:49  [140700151060224] INFO  Manager __init__:   max_workers=1
2018-02-25T19:30:49  [140700151060224] INFO  Manager __init__:   max_workers=False
2018-02-25T19:30:49  [140700151060224] INFO  Manager sync: eligible_zones=['watchdogportal.pl.'], eligible_targets=[], dry_run=False, force=True
2018-02-25T19:30:49  [140700151060224] INFO  Manager sync:   zone=watchdogportal.pl.
2018-02-25T19:30:49  [140700151060224] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-25T19:30:49  [140700151060224] INFO  YamlProvider[config] populate:   found 10 records
2018-02-25T19:30:49  [140700151060224] INFO  CloudflareProvider[cloudflare_shared] plan: desired=watchdogportal.pl.
2018-02-25T19:30:51  [140700151060224] INFO  CloudflareProvider[cloudflare_shared] populate:   found 10 records
2018-02-25T19:30:51  [140700151060224] INFO  CloudflareProvider[cloudflare_shared] plan:   filtered out 3 changes
2018-02-25T19:30:51  [140700151060224] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=1, Deletes=0, Existing Records=10
2018-02-25T19:30:51  [140700151060224] INFO  Manager 
********************************************************************************
* watchdogportal.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <MxRecord MX 1, watchdogportal.pl., [''10 joanna.jawne.info.pl.'']> ->
*     <MxRecord MX 7200, watchdogportal.pl., [''10 joanna.jawne.info.pl.'']> (config)
*   Summary: Creates=0, Updates=1, Deletes=0, Existing Records=10
********************************************************************************

2018-02-25T19:30:51  [140700151060224] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
2018-02-25T19:30:51  [140700151060224] INFO  Manager sync:   1 total changes

On changes TTL on third record (TXT '' record):

$ octodns-sync --config-file=./env/production.yaml --doit watchdogportal.pl. --force
2018-02-25T19:31:40  [139696871728896] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-25T19:31:40  [139696871728896] INFO  Manager __init__:   max_workers=1
2018-02-25T19:31:40  [139696871728896] INFO  Manager __init__:   max_workers=False
2018-02-25T19:31:40  [139696871728896] INFO  Manager sync: eligible_zones=['watchdogportal.pl.'], eligible_targets=[], dry_run=False, force=True
2018-02-25T19:31:40  [139696871728896] INFO  Manager sync:   zone=watchdogportal.pl.
2018-02-25T19:31:40  [139696871728896] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-25T19:31:40  [139696871728896] INFO  YamlProvider[config] populate:   found 10 records
2018-02-25T19:31:40  [139696871728896] INFO  CloudflareProvider[cloudflare_shared] plan: desired=watchdogportal.pl.
2018-02-25T19:31:41  [139696871728896] INFO  CloudflareProvider[cloudflare_shared] populate:   found 10 records
2018-02-25T19:31:41  [139696871728896] INFO  CloudflareProvider[cloudflare_shared] plan:   filtered out 3 changes
2018-02-25T19:31:41  [139696871728896] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=1, Deletes=0, Existing Records=10
2018-02-25T19:31:41  [139696871728896] INFO  Manager 
********************************************************************************
* watchdogportal.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <TxtRecord TXT 1, watchdogportal.pl., ['google-site-verification=g8uMdo5MzUDqNJ6qObquyGwJrL8vU7by_ahgpX9yjes', 'v=spf1 include:_spf.emaillabs.net.pl ~all']> ->
*     <TxtRecord TXT 7200, watchdogportal.pl., ['google-site-verification=g8uMdo5MzUDqNJ6qObquyGwJrL8vU7by_ahgpX9yjes', 'v=spf1 include:_spf.emaillabs.net.pl ~all']> (config)
*   Summary: Creates=0, Updates=1, Deletes=0, Existing Records=10
********************************************************************************

2018-02-25T19:31:41  [139696871728896] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
2018-02-25T19:31:42  [139696871728896] INFO  Manager sync:   1 total changes

On changes on next two records:

$ octodns-sync --config-file=./env/production.yaml --doit watchdogportal.pl. --force
2018-02-25T19:32:16  [140540365707008] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-25T19:32:16  [140540365707008] INFO  Manager __init__:   max_workers=1
2018-02-25T19:32:16  [140540365707008] INFO  Manager __init__:   max_workers=False
2018-02-25T19:32:16  [140540365707008] INFO  Manager sync: eligible_zones=['watchdogportal.pl.'], eligible_targets=[], dry_run=False, force=True
2018-02-25T19:32:16  [140540365707008] INFO  Manager sync:   zone=watchdogportal.pl.
2018-02-25T19:32:16  [140540365707008] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-25T19:32:16  [140540365707008] INFO  YamlProvider[config] populate:   found 10 records
2018-02-25T19:32:16  [140540365707008] INFO  CloudflareProvider[cloudflare_shared] plan: desired=watchdogportal.pl.
2018-02-25T19:32:23  [140540365707008] INFO  CloudflareProvider[cloudflare_shared] populate:   found 10 records
2018-02-25T19:32:23  [140540365707008] INFO  CloudflareProvider[cloudflare_shared] plan:   filtered out 2 changes
2018-02-25T19:32:23  [140540365707008] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=2, Deletes=0, Existing Records=10
2018-02-25T19:32:23  [140540365707008] INFO  Manager 
********************************************************************************
* watchdogportal.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <ARecord A 120, archiwum.watchdogportal.pl., ['31.6.70.229']> ->
*     <ARecord A 7200, archiwum.watchdogportal.pl., ['31.6.70.229']> (config)
*   Update
*     <CnameRecord CNAME 1, emaillabs._domainkey.watchdogportal.pl., emaillabs._domainkey.emaillabs.net.pl.> ->
*     <CnameRecord CNAME 7200, emaillabs._domainkey.watchdogportal.pl., emaillabs._domainkey.emaillabs.net.pl.> (config)
*   Summary: Creates=0, Updates=2, Deletes=0, Existing Records=10
********************************************************************************

2018-02-25T19:32:23  [140540365707008] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
2018-02-25T19:32:24  [140540365707008] INFO  Manager sync:   2 total changes

On change next record:

$ octodns-sync --config-file=./env/production.yaml --doit watchdogportal.pl. --force
2018-02-25T19:33:08  [140199409436416] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-25T19:33:08  [140199409436416] INFO  Manager __init__:   max_workers=1
2018-02-25T19:33:08  [140199409436416] INFO  Manager __init__:   max_workers=False
2018-02-25T19:33:08  [140199409436416] INFO  Manager sync: eligible_zones=['watchdogportal.pl.'], eligible_targets=[], dry_run=False, force=True
2018-02-25T19:33:08  [140199409436416] INFO  Manager sync:   zone=watchdogportal.pl.
2018-02-25T19:33:08  [140199409436416] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-25T19:33:08  [140199409436416] INFO  YamlProvider[config] populate:   found 10 records
2018-02-25T19:33:08  [140199409436416] INFO  CloudflareProvider[cloudflare_shared] plan: desired=watchdogportal.pl.
2018-02-25T19:33:09  [140199409436416] INFO  CloudflareProvider[cloudflare_shared] populate:   found 10 records
2018-02-25T19:33:09  [140199409436416] INFO  CloudflareProvider[cloudflare_shared] plan:   filtered out 1 changes
2018-02-25T19:33:09  [140199409436416] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=1, Deletes=0, Existing Records=10
2018-02-25T19:33:09  [140199409436416] INFO  Manager 
********************************************************************************
* watchdogportal.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <ARecord A 120, kursy.watchdogportal.pl., ['185.23.21.15']> ->
*     <ARecord A 7200, kursy.watchdogportal.pl., ['185.23.21.15']> (config)
*   Summary: Creates=0, Updates=1, Deletes=0, Existing Records=10
********************************************************************************

2018-02-25T19:33:09  [140199409436416] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
2018-02-25T19:33:10  [140199409436416] INFO  Manager sync:   1 total changes

On update MX record:

$ octodns-sync --config-file=./env/production.yaml --doit watchdogportal.pl. --force
2018-02-25T19:33:35  [140100456343296] INFO  Manager __init__: config_file=./env/production.yaml
2018-02-25T19:33:35  [140100456343296] INFO  Manager __init__:   max_workers=1
2018-02-25T19:33:35  [140100456343296] INFO  Manager __init__:   max_workers=False
2018-02-25T19:33:35  [140100456343296] INFO  Manager sync: eligible_zones=['watchdogportal.pl.'], eligible_targets=[], dry_run=False, force=True
2018-02-25T19:33:35  [140100456343296] INFO  Manager sync:   zone=watchdogportal.pl.
2018-02-25T19:33:35  [140100456343296] INFO  Manager sync:   sources=['config'] -> targets=['cloudflare_shared']
2018-02-25T19:33:35  [140100456343296] INFO  YamlProvider[config] populate:   found 10 records
2018-02-25T19:33:35  [140100456343296] INFO  CloudflareProvider[cloudflare_shared] plan: desired=watchdogportal.pl.
2018-02-25T19:33:37  [140100456343296] INFO  CloudflareProvider[cloudflare_shared] populate:   found 10 records
2018-02-25T19:33:37  [140100456343296] INFO  CloudflareProvider[cloudflare_shared] plan:   filtered out 1 changes
2018-02-25T19:33:37  [140100456343296] INFO  CloudflareProvider[cloudflare_shared] plan:   Creates=0, Updates=1, Deletes=0, Existing Records=10
2018-02-25T19:33:37  [140100456343296] INFO  Manager 
********************************************************************************
* watchdogportal.pl.
********************************************************************************
* cloudflare_shared (CloudflareProvider)
*   Update
*     <MxRecord MX 1, kursy.watchdogportal.pl., [''10 mx1.zenbox.pl.'', ''20 mx2.zenbox.pl.'', ''30 mx3.zenbox.pl.'']> ->
*     <MxRecord MX 7200, kursy.watchdogportal.pl., [''10 mx1.zenbox.pl.'', ''20 mx2.zenbox.pl.'', ''30 mx3.zenbox.pl.'']> (config)
*   Summary: Creates=0, Updates=1, Deletes=0, Existing Records=10
********************************************************************************

2018-02-25T19:33:37  [140100456343296] INFO  CloudflareProvider[cloudflare_shared] apply: making changes
Traceback (most recent call last):
  File "/home/adas/.virtualenvs/infra/bin/octodns-sync", line 11, in <module>
    load_entry_point('octodns==0.8.8', 'console_scripts', 'octodns-sync')()
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/cmds/sync.py", line 39, in main
    dry_run=not args.doit, force=args.force)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/manager.py", line 311, in sync
    total_changes += target.apply(plan)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/base.py", line 87, in apply
    self._apply(plan)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 458, in _apply
    getattr(self, '_apply_{}'.format(class_name))(change)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 416, in _apply_Update
    self._request('PUT', path, data=add_content)
  File "/home/adas/.virtualenvs/infra/local/lib/python2.7/site-packages/octodns/provider/cloudflare.py", line 80, in _request
    raise CloudflareError(resp.json())
octodns.provider.cloudflare.CloudflareError: A record with those settings already exists.

Records before changes :

kursy:
- ttl: 7200
  type: A
  value: 185.23.21.15
- ttl: 1
  type: MX
  values:
  - exchange: mx1.zenbox.pl.
    preference: 10
  - exchange: mx2.zenbox.pl.
    preference: 20
  - exchange: mx3.zenbox.pl.
    preference: 30

Record after changes (records failings):

kursy:
- ttl: 7200
  type: A
  value: 185.23.21.15
- ttl: 7200
  type: MX
  values:
  - exchange: mx1.zenbox.pl.
    preference: 10
  - exchange: mx2.zenbox.pl.
    preference: 20
  - exchange: mx3.zenbox.pl.
    preference: 30

It looks there is MX records TTL update issue, no A record. The messages A record with those settings already exists. is misleading.

Moumoutaru commented 5 years ago

I ran into this as well but was unable to replicate it with an mx record changing the ttl from 1 to anything else.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.