Blame SOURCES/bz1470813-fencing-2-fix-power-timeout.patch

0e8ca9
From 4202a863b25e456b7e419cbfc33c45ae179eb760 Mon Sep 17 00:00:00 2001
0e8ca9
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
0e8ca9
Date: Thu, 15 Oct 2020 10:34:03 +0200
0e8ca9
Subject: [PATCH] fencing: fix power-timeout when using new disable-timeout
0e8ca9
 parameter
0e8ca9
0e8ca9
---
0e8ca9
 lib/fencing.py.py | 8 +++++++-
0e8ca9
 1 file changed, 7 insertions(+), 1 deletion(-)
0e8ca9
0e8ca9
diff --git a/lib/fencing.py.py b/lib/fencing.py.py
0e8ca9
index 4a41af02..4639a9a5 100644
0e8ca9
--- a/lib/fencing.py.py
0e8ca9
+++ b/lib/fencing.py.py
0e8ca9
@@ -10,6 +10,8 @@
0e8ca9
 import textwrap
0e8ca9
 import __main__
0e8ca9
 
0e8ca9
+import itertools
0e8ca9
+
0e8ca9
 RELEASE_VERSION = "@RELEASE_VERSION@"
0e8ca9
 
0e8ca9
 __all__ = ['atexit_handler', 'check_input', 'process_input', 'all_opt', 'show_docs',
0e8ca9
@@ -821,11 +823,15 @@ def async_set_multi_power_fn(connection, options, set_power_fn, get_power_fn, re
0e8ca9
 			set_power_fn(connection, options)
0e8ca9
 			time.sleep(int(options["--power-wait"]))
0e8ca9
 
0e8ca9
-		for _ in range(int(options["--power-timeout"])):
0e8ca9
+		for _ in itertools.count(1):
0e8ca9
 			if get_multi_power_fn(connection, options, get_power_fn) != options["--action"]:
0e8ca9
 				time.sleep(1)
0e8ca9
 			else:
0e8ca9
 				return True
0e8ca9
+
0e8ca9
+			if int(options["--power-timeout"]) > 0 and _ >= int(options["--power-timeout"]):
0e8ca9
+				break
0e8ca9
+
0e8ca9
 	return False
0e8ca9
 
0e8ca9
 def sync_set_multi_power_fn(connection, options, sync_set_power_fn, retry_attempts):