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

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