diff options
author | Martin Babinsky <mbabinsk@redhat.com> | 2017-03-15 13:31:27 +0100 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2017-03-15 16:39:39 +0100 |
commit | 069948466e81d99a0dd48ffffa32af50351d0189 (patch) | |
tree | 6c4215a7273758dd94ec2858ecf57c33d830090c | |
parent | bd18b5f91e3f98fa877def245c54c1cd33bd372e (diff) | |
download | freeipa-069948466e81d99a0dd48ffffa32af50351d0189.tar.gz freeipa-069948466e81d99a0dd48ffffa32af50351d0189.tar.xz freeipa-069948466e81d99a0dd48ffffa32af50351d0189.zip |
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 <mbasti@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
-rw-r--r-- | ipaserver/install/replication.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py index 1f1378354..3cd871e5d 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): |