From 29147b006f4c4bba10a0f1f624b67f30e09e26b4 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Dec 08 2015 09:56:43 +0000 Subject: [PATCH 1/2] _callMethod(): fix exception handling Rethrow the exception that interests us, not the one from iteratable check above. --- diff --git a/koji/__init__.py b/koji/__init__.py index 8e297dc..4a77bdb 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -1979,14 +1979,14 @@ class ClientSession(object): if ('certificate revoked' in ssl_reason or 'certificate expired' in ssl_reason): # There's no point in retrying for this - raise + raise e if not self.logged_in: #in the past, non-logged-in sessions did not retry. For compatibility purposes #this behavior is governed by the anon_retry opt. if not self.opts.get('anon_retry',False): - raise + raise e if tries > max_retries: - raise + raise e #otherwise keep retrying if self.logger.isEnabledFor(logging.DEBUG): tb_str = ''.join(traceback.format_exception(*sys.exc_info())) From b5a937697bc8f50b9600062361bb6170462b0326 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Dec 08 2015 09:56:43 +0000 Subject: [PATCH 2/2] Retry anonymous requests once Server likes to close connections sometimes and we log off before watching tasks. Let's try to reconnect once, but don't fall back into sleeping and more retries to keep compatibility with previous behavior (see comment). https://bugzilla.redhat.com/show_bug.cgi?id=1274517 --- diff --git a/koji/__init__.py b/koji/__init__.py index 4a77bdb..e2ffe5a 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -1923,6 +1923,13 @@ class ClientSession(object): debug = self.opts.get('debug',False) max_retries = self.opts.get('max_retries',30) interval = self.opts.get('retry_interval',20) + + if not self.logged_in: + #in the past, non-logged-in sessions did not retry. For compatibility purposes + #this behavior is governed by the anon_retry opt. + if not self.opts.get('anon_retry',False): + max_retries = 1 + while True: tries += 1 self.retries += 1 @@ -1980,11 +1987,6 @@ class ClientSession(object): 'certificate expired' in ssl_reason): # There's no point in retrying for this raise e - if not self.logged_in: - #in the past, non-logged-in sessions did not retry. For compatibility purposes - #this behavior is governed by the anon_retry opt. - if not self.opts.get('anon_retry',False): - raise e if tries > max_retries: raise e #otherwise keep retrying