From b7c00f2a1fe2cce3b731109e8748b50ad04e1aa2 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Thu, 17 Dec 2020 22:18:47 +0200 Subject: [PATCH] service: handle empty list of services to update their state When there are no services in LDAP that have specified states, we don't need to update their state. Fixes: https://pagure.io/freeipa/issue/8623 Signed-off-by: Alexander Bokovoy Reviewed-By: Christian Heimes --- ipaserver/install/service.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py index 2afb251fc..3603ad393 100644 --- a/ipaserver/install/service.py +++ b/ipaserver/install/service.py @@ -252,12 +252,18 @@ def _set_services_state(fqdn, dest_state): rules=ldap2.MATCH_ALL ) - entries = ldap2.get_entries( - search_base, - filter=search_filter, - scope=api.Backend.ldap2.SCOPE_ONELEVEL, - attrs_list=['cn', 'ipaConfigString'] - ) + try: + entries = ldap2.get_entries( + search_base, + filter=search_filter, + scope=api.Backend.ldap2.SCOPE_ONELEVEL, + attrs_list=['cn', 'ipaConfigString'] + ) + except errors.EmptyResult: + logger.debug("No services with a state from %s, ignoring", + list(source_states)) + return + for entry in entries: name = entry['cn'] cfgstrings = entry.setdefault('ipaConfigString', [])