]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
contextutil: sleep between tries in safe_while again
authorKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Tue, 6 Aug 2024 22:42:32 +0000 (00:42 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Tue, 6 Aug 2024 23:49:20 +0000 (01:49 +0200)
This patch fixes an issue introduced within PR #1816,
that when tries are < 0 (e.g. -1) there is no sleep
occurred between tries.

It also fixes error message, so we repot correct
number of tries we've done now.

Fixes: ee43f87cfe88a8155566b662750d663c1d8742ff
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@clyso.com>
teuthology/contextutil.py

index dd6d2d68a72ebc532ca8b956b49c2301297890c4..8e53e5439b8f1361a23528d570cc957db4f1d192 100644 (file)
@@ -115,20 +115,20 @@ class safe_while(object):
 
         msg = msg.format(
             action=self.action,
-            tries=self.counter,
+            tries=self.counter - 1,
             total=self.total_seconds,
         )
         return msg
 
     def __call__(self):
-        if self.tries < 0:
-            return True
         self.counter += 1
         if self.counter == 1:
             return True
+        def must_stop():
+            return self.tries > 0 and self.counter > self.tries
         if ((self.timeout > 0 and
              self.total_seconds >= self.timeout) or
-            (self.timeout == 0 and self.counter > self.tries)):
+            (self.timeout == 0 and must_stop())):
             error_msg = self._make_error_msg()
             if self._raise:
                 raise MaxWhileTries(error_msg)