Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dry run didn't catch improperly formatted MX record, broke with --doit #600

Open
zachlatta opened this issue Aug 31, 2020 · 1 comment
Open

Comments

@zachlatta
Copy link

@zachlatta zachlatta commented Aug 31, 2020

Hi there, we use OctoDNS to manage Hack Club's DNS records and it's amazing! It means we can open source all of our DNS records at hackclub/dns. I love the idea of "infrastructure as code" and OctoDNS helps us a lot.

We recently ran into an issue where someone added an MX record with the exchange value 100 mx.sendgrid.net.. We have a test suite that does a dry run, which didn't surface any issues with this value, but when it was ran with --doit, we got an ambiguous error.

I was able to figure out that we had to remove 100 from the record value, which fixed --doit. Setting exchange to just mx.sendgrid.net. worked fine, but as a user I would expect OctoDNS to surface this error during the dry run.

Here's the error log:

...(many lines above this)...
*   Create <MxRecord MX 1, front-mail.hackclub.com., [''1 100 mx.sendgrid.net.'']> (config)
*   Create <TxtRecord TXT 1, front-mail.hackclub.com., ['v=spf1 include:sendgrid.net ~all']> (config)
*   Summary: Creates=3, Updates=1, Deletes=0, Existing Records=184
********************************************************************************


2020-08-30T23:28:15  [140229093717632] INFO  DnsimpleProvider[dnsimple] apply: making changes
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/2.7.18/x64/bin/octodns-sync", line 11, in <module>
    load_entry_point('octodns==0.9.10', 'console_scripts', 'octodns-sync')()
  File "/opt/hostedtoolcache/Python/2.7.18/x64/lib/python2.7/site-packages/octodns/cmds/sync.py", line 39, in main
    dry_run=not args.doit, force=args.force)
  File "/opt/hostedtoolcache/Python/2.7.18/x64/lib/python2.7/site-packages/octodns/manager.py", line 344, in sync
    total_changes += target.apply(plan)
  File "/opt/hostedtoolcache/Python/2.7.18/x64/lib/python2.7/site-packages/octodns/provider/base.py", line 95, in apply
    self._apply(plan)
  File "/opt/hostedtoolcache/Python/2.7.18/x64/lib/python2.7/site-packages/octodns/provider/dnsimple.py", line 416, in _apply
    getattr(self, '_apply_{}'.format(class_name))(change)
  File "/opt/hostedtoolcache/Python/2.7.18/x64/lib/python2.7/site-packages/octodns/provider/dnsimple.py", line 387, in _apply_Create
    self._client.record_create(new.zone.name[:-1], params)
  File "/opt/hostedtoolcache/Python/2.7.18/x64/lib/python2.7/site-packages/octodns/provider/dnsimple.py", line 78, in record_create

And here's the commit in our repo that ran into this issue: hackclub/dns@48ac4d1#diff-be3b615b181f7f7bf89114f9ef473a86R416

zachlatta added a commit to hackclub/dns that referenced this issue Aug 31, 2020
It looks like there was an issue where "exchange: 100 mx.sendgrid.net."
should have been "exchange: mx.sendgrid.net.". OctoDNS should have
caught this with its tests, but missed it.

Please note: if the "100" was intended to specify the preference (AKA
priority) for the MX record, the preference value should be updated from
"1" to "100" in the YAML.

I filed github/octodns#600 in OctoDNS so they
can hopefully fix this.
@ross
Copy link
Contributor

@ross ross commented Aug 31, 2020

Hi @zachlatta. There are some existing "validations" on MX records,

@classmethod
def validate(cls, data, _type):
if not isinstance(data, (list, tuple)):
data = (data,)
reasons = []
for value in data:
try:
try:
int(value['preference'])
except KeyError:
int(value['priority'])
except KeyError:
reasons.append('missing preference')
except ValueError:
reasons.append('invalid preference "{}"'
.format(value['preference']))
exchange = None
try:
exchange = value.get('exchange', None) or value['value']
if not exchange.endswith('.'):
reasons.append('MX value "{}" missing trailing .'
.format(exchange))
except KeyError:
reasons.append('missing exchange')
return reasons
, but nothing that specifically look for that sort of case.

It could probably be caught by looking for spaces in the name and would likely apply equally well to a number of other types of values: ALIAS, CNAME, SRV. Would welcome PRs w/tests to that effect. Otherwise this issue can track it as a TODO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.