changeset 2768:cb34af35af6f

core (disco): client.disco.requestInfo failure are re-raised: so far, requestInfo failure where logged as a warning, and an empty disco was returned. This prevented the requesting entity to know about the error, so now the error is logged and re-raised. CancelError are converted to TimeoutError (requestInfo is only cancelled on timeout). An empty disco is still cached in case of failure, to avoid re-waiting for the entity on next request.
author Goffi <goffi@goffi.org>
date Fri, 11 Jan 2019 19:48:20 +0100
parents a97c43dc4924
children 9282b289b964
files sat/memory/disco.py
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/sat/memory/disco.py	Fri Jan 11 19:44:46 2019 +0100
+++ b/sat/memory/disco.py	Fri Jan 11 19:48:20 2019 +0100
@@ -189,21 +189,25 @@
             def infosEb(fail):
                 if fail.check(defer.CancelledError):
                     reason = u"request time-out"
+                    fail = failure.Failure(exceptions.TimeOutError(fail.message))
                 else:
                     try:
                         reason = unicode(fail.value)
                     except AttributeError:
                         reason = unicode(fail)
-                    log.warning(
-                        u"Error while requesting disco infos from {jid}: {reason}".format(
-                            jid=jid_.full(), reason=reason
-                        )
+
+                log.warning(
+                    u"Error while requesting disco infos from {jid}: {reason}".format(
+                        jid=jid_.full(), reason=reason
                     )
+                )
+
+                # XXX we set empty disco in cache, to avoid getting an error or waiting
+                # for a timeout again the next time
                 self.host.memory.updateEntityData(
                     jid_, C.ENTITY_CAP_HASH, CAP_HASH_ERROR, profile_key=client.profile
                 )
-                disco_infos = self.hashes[CAP_HASH_ERROR]
-                return disco_infos
+                raise fail
 
             d = client.disco.requestInfo(jid_, nodeIdentifier=node)
             d.addCallback(infosCb)