From 69b42f0c80f392b20526b5ff8155fc1aa633dd7d Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Tue, 3 Nov 2020 12:54:01 -0500 Subject: [PATCH] Catch EmptyResult exception in update_idranges If no results are returned then find_entries will raise EmptyResult and not NotFound. NotFound is returned if the search base doesn't exist. The test for not entries can be removed as well since this is the EmptyResult case. In case of a NotFound this will be handled by the ExecutionError clause. Found with https://pagure.io/freeipa/issue/8555 Signed-off-by: Rob Crittenden Reviewed-By: Florence Blanc-Renaud --- ipaserver/install/plugins/update_idranges.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ipaserver/install/plugins/update_idranges.py b/ipaserver/install/plugins/update_idranges.py index 9fce5366a..cce83b12c 100644 --- a/ipaserver/install/plugins/update_idranges.py +++ b/ipaserver/install/plugins/update_idranges.py @@ -51,7 +51,7 @@ class update_idrange_type(Updater): (entries, truncated) = ldap.find_entries(search_filter, ['objectclass'], base_dn, time_limit=0, size_limit=0) - except errors.NotFound: + except errors.EmptyResult: logger.debug("update_idrange_type: no ID range without " "type set found") return False, [] @@ -61,11 +61,6 @@ class update_idrange_type(Updater): "of ranges with no type set: %s", e) return False, [] - if not entries: - # No entry was returned, rather break than continue cycling - logger.debug("update_idrange_type: no ID range was returned") - return False, [] - logger.debug("update_idrange_type: found %d " "idranges to update, truncated: %s", len(entries), truncated)