URL: https://github.com/freeipa/freeipa/pull/689 Author: alex-zel Title: #689: Sort SRV records by priority Action: synchronized
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/689/head:pr689 git checkout pr689
From 283da88845c65d5cd3b4ce6b5e32c17fc3c5fb98 Mon Sep 17 00:00:00 2001 From: Alex Zeleznikov <a...@iucc.ac.il> Date: Tue, 4 Apr 2017 09:42:10 +0300 Subject: [PATCH 1/3] Sort SRV records by priority In some cases where multiple SRV records are present, LDAP and Kerberos records were returned in different order, causing replication issues in a multi master enviorment. --- ipaclient/install/ipadiscovery.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py index 46e05c9..b30e7de 100644 --- a/ipaclient/install/ipadiscovery.py +++ b/ipaclient/install/ipadiscovery.py @@ -22,13 +22,14 @@ import six from ipapython.ipa_log_manager import root_logger -from dns import resolver, rdatatype from dns.exception import DNSException +from dns import resolver, rdatatype from ipalib import errors from ipapython import ipaldap from ipaplatform.paths import paths from ipapython.ipautil import valid_ip, realm_to_suffix from ipapython.dn import DN +from operator import attrgetter NOT_FQDN = -1 NO_LDAP_SERVER = -2 @@ -493,6 +494,7 @@ def ipadns_search_srv(self, domain, srv_record_name, default_port, try: answers = resolver.query(qname, rdatatype.SRV) + answers = sorted(answers, key=attrgetter('priority')) except DNSException as e: root_logger.debug("DNS record not found: %s", e.__class__.__name__) answers = [] From 78cac5d5ed7b1b857093667dad66dc1dc6f86670 Mon Sep 17 00:00:00 2001 From: Alex Zel <alex88...@gmail.com> Date: Thu, 6 Apr 2017 10:06:36 +0300 Subject: [PATCH 2/3] Update ipadiscovery.py --- ipaclient/install/ipadiscovery.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py index b30e7de..c929a35 100644 --- a/ipaclient/install/ipadiscovery.py +++ b/ipaclient/install/ipadiscovery.py @@ -17,19 +17,19 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +import operator import socket import six from ipapython.ipa_log_manager import root_logger -from dns.exception import DNSException from dns import resolver, rdatatype +from dns.exception import DNSException from ipalib import errors from ipapython import ipaldap from ipaplatform.paths import paths from ipapython.ipautil import valid_ip, realm_to_suffix from ipapython.dn import DN -from operator import attrgetter NOT_FQDN = -1 NO_LDAP_SERVER = -2 @@ -494,7 +494,7 @@ def ipadns_search_srv(self, domain, srv_record_name, default_port, try: answers = resolver.query(qname, rdatatype.SRV) - answers = sorted(answers, key=attrgetter('priority')) + answers = sorted(answers, key=operator.attrgetter('priority')) except DNSException as e: root_logger.debug("DNS record not found: %s", e.__class__.__name__) answers = [] From ca4b37023314fc5125defc015a1fdafaacef1be2 Mon Sep 17 00:00:00 2001 From: Alex Zeleznikov <a...@iucc.ac.il> Date: Tue, 4 Apr 2017 09:42:10 +0300 Subject: [PATCH 3/3] Sort SRV records by priority In some cases where multiple SRV records are present, LDAP and Kerberos records were returned in different order, causing replication issues in a multi master enviorment. Update ipadiscovery.py --- ipaclient/install/ipadiscovery.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py index 46e05c9..c929a35 100644 --- a/ipaclient/install/ipadiscovery.py +++ b/ipaclient/install/ipadiscovery.py @@ -17,6 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +import operator import socket import six @@ -493,6 +494,7 @@ def ipadns_search_srv(self, domain, srv_record_name, default_port, try: answers = resolver.query(qname, rdatatype.SRV) + answers = sorted(answers, key=operator.attrgetter('priority')) except DNSException as e: root_logger.debug("DNS record not found: %s", e.__class__.__name__) answers = []
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code