From 66bef83cbc9c77bb4930ed2d54cb88ed9fa649d8 Mon Sep 17 00:00:00 2001 From: Colin Nicholson Date: Thu, 20 Jan 2011 16:01:37 +0000 Subject: [PATCH 1/2] also catch NXDOMAIN exception --- swift/common/middleware/cname_lookup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/swift/common/middleware/cname_lookup.py b/swift/common/middleware/cname_lookup.py index e48d209e54..950562b834 100644 --- a/swift/common/middleware/cname_lookup.py +++ b/swift/common/middleware/cname_lookup.py @@ -17,6 +17,7 @@ from webob import Request from webob.exc import HTTPBadRequest import dns.resolver from dns.exception import DNSException +from dns.resolver import NXDOMAIN from swift.common.utils import cache_from_env, get_logger @@ -34,7 +35,7 @@ def lookup_cname(domain): # pragma: no cover result = answer.items[0].to_text() result = result.rstrip('.') return ttl, result - except DNSException: + except (DNSException, NXDOMAIN): return 0, None From 74a39c0f26ea5d1770958afd2a445ef4d6aecdf1 Mon Sep 17 00:00:00 2001 From: John Dickinson Date: Thu, 20 Jan 2011 14:15:05 -0600 Subject: [PATCH 2/2] added NoAnswer error catching --- swift/common/middleware/cname_lookup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swift/common/middleware/cname_lookup.py b/swift/common/middleware/cname_lookup.py index 950562b834..f13155c1fe 100644 --- a/swift/common/middleware/cname_lookup.py +++ b/swift/common/middleware/cname_lookup.py @@ -17,7 +17,7 @@ from webob import Request from webob.exc import HTTPBadRequest import dns.resolver from dns.exception import DNSException -from dns.resolver import NXDOMAIN +from dns.resolver import NXDOMAIN, NoAnswer from swift.common.utils import cache_from_env, get_logger @@ -35,7 +35,7 @@ def lookup_cname(domain): # pragma: no cover result = answer.items[0].to_text() result = result.rstrip('.') return ttl, result - except (DNSException, NXDOMAIN): + except (DNSException, NXDOMAIN, NoAnswer): return 0, None