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 <rcritten@redhat.com>
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
Rob Crittenden 2020-11-03 12:54:01 -05:00
parent f86250a9a5
commit 69b42f0c80

View File

@ -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)