Merge lp:~thedac/charm-helpers/fix-dns into lp:charm-helpers

Proposed by David Ames
Status: Merged
Merged at revision: 673
Proposed branch: lp:~thedac/charm-helpers/fix-dns
Merge into: lp:charm-helpers
Diff against target: 16 lines (+5/-1)
1 file modified
charmhelpers/contrib/network/ip.py (+5/-1)
To merge this branch: bzr merge lp:~thedac/charm-helpers/fix-dns
Reviewer Review Type Date Requested Status
Corey Bryant (community) Approve
Marco Ceppi Approve
Review via email: mp+309061@code.launchpad.net

Description of the change

Do not Traceback on failure to resolve DNS

To post a comment you must log in.
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

I think we'd want to try to avoid blanket except blocks. Is it possible to add exception handling for the exceptions that are thrown during DNS resolution failures?

otherwise LGTM +1

review: Approve
lp:~thedac/charm-helpers/fix-dns updated
653. By David Ames

Be more explicit in the eception catch

Revision history for this message
Corey Bryant (corey.bryant) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/network/ip.py'
2--- charmhelpers/contrib/network/ip.py 2016-09-22 11:44:20 +0000
3+++ charmhelpers/contrib/network/ip.py 2016-11-07 23:10:41 +0000
4@@ -424,7 +424,11 @@
5 else:
6 return None
7
8- answers = dns.resolver.query(address, rtype)
9+ try:
10+ answers = dns.resolver.query(address, rtype)
11+ except dns.resolver.NXDOMAIN as e:
12+ return None
13+
14 if answers:
15 return str(answers[0])
16 return None

Subscribers

People subscribed via source and target branches