diff --git a/swift/common/middleware/cname_lookup.py b/swift/common/middleware/cname_lookup.py index e48d209e54..f13155c1fe 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, NoAnswer 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, NoAnswer): return 0, None