dns: Handle SERVFAIL in check if domain already exists.

In cases where domain is already delegated to IPA prior installation
we might get timeout or SERVFAIL. The answer depends on the recursive
server we are using for the check.

Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
Petr Spacek 2015-12-16 13:37:39 +01:00 committed by Petr Vobornik
parent c265e8736e
commit 58331208a5
3 changed files with 10 additions and 9 deletions

View File

@ -41,7 +41,7 @@ import locale
import collections import collections
from dns import resolver, rdatatype, reversename from dns import resolver, rdatatype, reversename
from dns.exception import DNSException, Timeout from dns.exception import DNSException
import six import six
from six.moves import input from six.moves import input
from six.moves import urllib from six.moves import urllib
@ -1046,7 +1046,7 @@ def reverse_record_exists(ip_address):
return True return True
def check_zone_overlap(zone, raise_on_timeout=True): def check_zone_overlap(zone, raise_on_error=True):
root_logger.info("Checking DNS domain %s, please wait ..." % zone) root_logger.info("Checking DNS domain %s, please wait ..." % zone)
if not isinstance(zone, DNSName): if not isinstance(zone, DNSName):
zone = DNSName(zone).make_absolute() zone = DNSName(zone).make_absolute()
@ -1058,10 +1058,9 @@ def check_zone_overlap(zone, raise_on_timeout=True):
try: try:
containing_zone = resolver.zone_for_name(zone) containing_zone = resolver.zone_for_name(zone)
except Timeout as e: except DNSException as e:
msg = ("DNS check for domain %s failed: %s. Please make sure that the " msg = ("DNS check for domain %s failed: %s." % (zone, e))
"domain is properly delegated to this IPA server." % (zone, e)) if raise_on_error:
if raise_on_timeout:
raise ValueError(msg) raise ValueError(msg)
else: else:
root_logger.warning(msg) root_logger.warning(msg)

View File

@ -291,7 +291,7 @@ def read_reverse_zone(default, ip_address, allow_zone_overlap=False):
continue continue
if not allow_zone_overlap: if not allow_zone_overlap:
try: try:
ipautil.check_zone_overlap(zone, raise_on_timeout=False) ipautil.check_zone_overlap(zone, raise_on_error=False)
except ValueError as e: except ValueError as e:
root_logger.error("Reverse zone %s will not be used: %s" root_logger.error("Reverse zone %s will not be used: %s"
% (zone, e)) % (zone, e))

View File

@ -126,10 +126,12 @@ def install_check(standalone, replica, options, hostname):
domain = dnsutil.DNSName(util.normalize_zone(api.env.domain)) domain = dnsutil.DNSName(util.normalize_zone(api.env.domain))
print("Checking DNS domain %s, please wait ..." % domain) print("Checking DNS domain %s, please wait ..." % domain)
try: try:
ipautil.check_zone_overlap(domain, raise_on_timeout=False) ipautil.check_zone_overlap(domain, raise_on_error=False)
except ValueError as e: except ValueError as e:
if options.force or options.allow_zone_overlap: if options.force or options.allow_zone_overlap:
root_logger.warning(e.message) root_logger.warning("%s Please make sure that the domain is "
"properly delegated to this IPA server.",
e.message)
else: else:
raise e raise e