From 069948466e81d99a0dd48ffffa32af50351d0189 Mon Sep 17 00:00:00 2001 From: Martin Babinsky Date: Mar 15 2017 15:39:39 +0000 Subject: Make wait_for_entry raise exceptions Instead of only logging errors when timeout is reached or query for the entry fails for other reasons, `wait_for_entry` should raise exceptions so that we can handle them in caller or let them propagate and fail early. https://pagure.io/freeipa/issue/6739 Reviewed-By: Martin Basti Reviewed-By: Alexander Bokovoy --- diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py index 1f13783..3cd871e 100644 --- a/ipaserver/install/replication.py +++ b/ipaserver/install/replication.py @@ -177,7 +177,7 @@ def wait_for_entry(connection, dn, timeout=7200, attr='', quiet=True): pass # no entry yet except Exception as e: # badness root_logger.error("Error reading entry %s: %s", dn, e) - break + raise if not entry: if not quiet: sys.stdout.write(".") @@ -185,13 +185,10 @@ def wait_for_entry(connection, dn, timeout=7200, attr='', quiet=True): time.sleep(1) if not entry and int(time.time()) > timeout: - root_logger.error( - "wait_for_entry timeout for %s for %s", connection, dn) + raise errors.NotFound( + reason="wait_for_entry timeout for %s for %s" % (connection, dn)) elif entry and not quiet: root_logger.error("The waited for entry is: %s", entry) - elif not entry: - root_logger.error( - "Error: could not read entry %s from %s", dn, connection) class ReplicationManager(object):