Blame SOURCES/bz2166249-01-fix-stonith-watchdog-timeout-offline-update.patch

c7b72c
From 166fd04bb5505f29463088080044689f15635018 Mon Sep 17 00:00:00 2001
c7b72c
From: Ondrej Mular <omular@redhat.com>
c7b72c
Date: Tue, 31 Jan 2023 17:44:16 +0100
c7b72c
Subject: [PATCH] fix update of stonith-watchdog-timeout when cluster is not
c7b72c
 running
c7b72c
c7b72c
---
c7b72c
 pcs/lib/communication/sbd.py                  |  4 +-
c7b72c
 .../lib/commands/sbd/test_disable_sbd.py      | 10 ++--
c7b72c
 .../tier0/lib/commands/sbd/test_enable_sbd.py | 49 ++++++++++---------
c7b72c
 pcsd/pcs.rb                                   | 17 +++++--
c7b72c
 4 files changed, 48 insertions(+), 32 deletions(-)
c7b72c
c7b72c
diff --git a/pcs/lib/communication/sbd.py b/pcs/lib/communication/sbd.py
c7b72c
index f31bf16f..83d912b2 100644
c7b72c
--- a/pcs/lib/communication/sbd.py
c7b72c
+++ b/pcs/lib/communication/sbd.py
c7b72c
@@ -98,8 +98,8 @@ class StonithWatchdogTimeoutAction(
c7b72c
         )
c7b72c
         if report_item is None:
c7b72c
             self._on_success()
c7b72c
-            return []
c7b72c
-        self._report(report_item)
c7b72c
+        else:
c7b72c
+            self._report(report_item)
c7b72c
         return self._get_next_list()
c7b72c
 
c7b72c
 
c7b72c
diff --git a/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py b/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py
c7b72c
index 13135fb2..f8f165bf 100644
c7b72c
--- a/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py
c7b72c
+++ b/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py
c7b72c
@@ -19,7 +19,7 @@ class DisableSbd(TestCase):
c7b72c
         self.config.corosync_conf.load(filename=self.corosync_conf_name)
c7b72c
         self.config.http.host.check_auth(node_labels=self.node_list)
c7b72c
         self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero(
c7b72c
-            node_labels=self.node_list[:1]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.disable_sbd(node_labels=self.node_list)
c7b72c
         disable_sbd(self.env_assist.get_env())
c7b72c
@@ -56,7 +56,7 @@ class DisableSbd(TestCase):
c7b72c
         self.config.corosync_conf.load(filename=self.corosync_conf_name)
c7b72c
         self.config.http.host.check_auth(node_labels=self.node_list)
c7b72c
         self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero(
c7b72c
-            node_labels=self.node_list[:1]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.disable_sbd(node_labels=self.node_list)
c7b72c
 
c7b72c
@@ -158,7 +158,9 @@ class DisableSbd(TestCase):
c7b72c
             ]
c7b72c
         )
c7b72c
         self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero(
c7b72c
-            node_labels=online_nodes_list[:1]
c7b72c
+            communication_list=[
c7b72c
+                [dict(label=node)] for node in self.node_list[1:]
c7b72c
+            ],
c7b72c
         )
c7b72c
         self.config.http.sbd.disable_sbd(node_labels=online_nodes_list)
c7b72c
         disable_sbd(self.env_assist.get_env(), ignore_offline_nodes=True)
c7b72c
@@ -291,7 +293,7 @@ class DisableSbd(TestCase):
c7b72c
         self.config.corosync_conf.load(filename=self.corosync_conf_name)
c7b72c
         self.config.http.host.check_auth(node_labels=self.node_list)
c7b72c
         self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero(
c7b72c
-            node_labels=self.node_list[:1]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.disable_sbd(
c7b72c
             communication_list=[
c7b72c
diff --git a/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py b/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py
c7b72c
index be479a34..77863d5e 100644
c7b72c
--- a/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py
c7b72c
+++ b/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py
c7b72c
@@ -130,7 +130,7 @@ class OddNumOfNodesSuccess(TestCase):
c7b72c
             node_labels=self.node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.node_list[0]]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -164,7 +164,7 @@ class OddNumOfNodesSuccess(TestCase):
c7b72c
             node_labels=self.node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.node_list[0]]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -218,7 +218,7 @@ class OddNumOfNodesDefaultsSuccess(TestCase):
c7b72c
             node_labels=self.node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.node_list[0]]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -248,7 +248,7 @@ class OddNumOfNodesDefaultsSuccess(TestCase):
c7b72c
             node_labels=self.node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.node_list[0]]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -351,7 +351,7 @@ class WatchdogValidations(TestCase):
c7b72c
             node_labels=self.node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.node_list[0]]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -407,7 +407,7 @@ class EvenNumOfNodes(TestCase):
c7b72c
             node_labels=self.node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.node_list[0]]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -443,7 +443,7 @@ class EvenNumOfNodes(TestCase):
c7b72c
             node_labels=self.node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.node_list[0]]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -480,7 +480,7 @@ class EvenNumOfNodes(TestCase):
c7b72c
             node_labels=self.node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.node_list[0]]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -513,7 +513,7 @@ class EvenNumOfNodes(TestCase):
c7b72c
             node_labels=self.node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.node_list[0]]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -604,7 +604,9 @@ class OfflineNodes(TestCase):
c7b72c
             node_labels=self.online_node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.online_node_list[0]]
c7b72c
+            communication_list=[
c7b72c
+                [dict(label=node)] for node in self.online_node_list
c7b72c
+            ],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.online_node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -644,7 +646,9 @@ class OfflineNodes(TestCase):
c7b72c
             node_labels=self.online_node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.online_node_list[0]]
c7b72c
+            communication_list=[
c7b72c
+                [dict(label=node)] for node in self.online_node_list
c7b72c
+            ],
c7b72c
         )
c7b72c
         self.config.http.sbd.enable_sbd(node_labels=self.online_node_list)
c7b72c
         enable_sbd(
c7b72c
@@ -1228,7 +1232,7 @@ class FailureHandling(TestCase):
c7b72c
             node_labels=self.node_list,
c7b72c
         )
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
-            node_labels=[self.node_list[0]]
c7b72c
+            communication_list=[[dict(label=node)] for node in self.node_list],
c7b72c
         )
c7b72c
 
c7b72c
     def _remove_calls(self, count):
c7b72c
@@ -1304,7 +1308,8 @@ class FailureHandling(TestCase):
c7b72c
         )
c7b72c
 
c7b72c
     def test_removing_stonith_wd_timeout_failure(self):
c7b72c
-        self._remove_calls(2)
c7b72c
+        self._remove_calls(len(self.node_list) + 1)
c7b72c
+
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
             communication_list=[
c7b72c
                 self.communication_list_failure[:1],
c7b72c
@@ -1333,7 +1338,7 @@ class FailureHandling(TestCase):
c7b72c
         )
c7b72c
 
c7b72c
     def test_removing_stonith_wd_timeout_not_connected(self):
c7b72c
-        self._remove_calls(2)
c7b72c
+        self._remove_calls(len(self.node_list) + 1)
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
             communication_list=[
c7b72c
                 self.communication_list_not_connected[:1],
c7b72c
@@ -1362,7 +1367,7 @@ class FailureHandling(TestCase):
c7b72c
         )
c7b72c
 
c7b72c
     def test_removing_stonith_wd_timeout_complete_failure(self):
c7b72c
-        self._remove_calls(2)
c7b72c
+        self._remove_calls(len(self.node_list) + 1)
c7b72c
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
c7b72c
             communication_list=[
c7b72c
                 self.communication_list_not_connected[:1],
c7b72c
@@ -1408,7 +1413,7 @@ class FailureHandling(TestCase):
c7b72c
         )
c7b72c
 
c7b72c
     def test_set_sbd_config_failure(self):
c7b72c
-        self._remove_calls(4)
c7b72c
+        self._remove_calls(len(self.node_list) + 1 + 2)
c7b72c
         self.config.http.sbd.set_sbd_config(
c7b72c
             communication_list=[
c7b72c
                 dict(
c7b72c
@@ -1455,7 +1460,7 @@ class FailureHandling(TestCase):
c7b72c
         )
c7b72c
 
c7b72c
     def test_set_corosync_conf_failed(self):
c7b72c
-        self._remove_calls(5)
c7b72c
+        self._remove_calls(len(self.node_list) + 1 + 3)
c7b72c
         self.config.env.push_corosync_conf(
c7b72c
             corosync_conf_text=_get_corosync_conf_text_with_atb(
c7b72c
                 self.corosync_conf_name
c7b72c
@@ -1479,7 +1484,7 @@ class FailureHandling(TestCase):
c7b72c
         )
c7b72c
 
c7b72c
     def test_check_sbd_invalid_data_format(self):
c7b72c
-        self._remove_calls(7)
c7b72c
+        self._remove_calls(len(self.node_list) + 1 + 5)
c7b72c
         self.config.http.sbd.check_sbd(
c7b72c
             communication_list=[
c7b72c
                 dict(
c7b72c
@@ -1518,7 +1523,7 @@ class FailureHandling(TestCase):
c7b72c
         )
c7b72c
 
c7b72c
     def test_check_sbd_failure(self):
c7b72c
-        self._remove_calls(7)
c7b72c
+        self._remove_calls(len(self.node_list) + 1 + 5)
c7b72c
         self.config.http.sbd.check_sbd(
c7b72c
             communication_list=[
c7b72c
                 dict(
c7b72c
@@ -1560,7 +1565,7 @@ class FailureHandling(TestCase):
c7b72c
         )
c7b72c
 
c7b72c
     def test_check_sbd_not_connected(self):
c7b72c
-        self._remove_calls(7)
c7b72c
+        self._remove_calls(len(self.node_list) + 1 + 5)
c7b72c
         self.config.http.sbd.check_sbd(
c7b72c
             communication_list=[
c7b72c
                 dict(
c7b72c
@@ -1603,7 +1608,7 @@ class FailureHandling(TestCase):
c7b72c
         )
c7b72c
 
c7b72c
     def test_get_online_targets_failed(self):
c7b72c
-        self._remove_calls(9)
c7b72c
+        self._remove_calls(len(self.node_list) + 1 + 7)
c7b72c
         self.config.http.host.check_auth(
c7b72c
             communication_list=self.communication_list_failure
c7b72c
         )
c7b72c
@@ -1628,7 +1633,7 @@ class FailureHandling(TestCase):
c7b72c
         )
c7b72c
 
c7b72c
     def test_get_online_targets_not_connected(self):
c7b72c
-        self._remove_calls(9)
c7b72c
+        self._remove_calls(len(self.node_list) + 1 + 7)
c7b72c
         self.config.http.host.check_auth(
c7b72c
             communication_list=self.communication_list_not_connected
c7b72c
         )
c7b72c
diff --git a/pcsd/pcs.rb b/pcsd/pcs.rb
c7b72c
index 6d8669d1..d79c863b 100644
c7b72c
--- a/pcsd/pcs.rb
c7b72c
+++ b/pcsd/pcs.rb
c7b72c
@@ -1642,13 +1642,22 @@ end
c7b72c
 def set_cluster_prop_force(auth_user, prop, val)
c7b72c
   cmd = ['property', 'set', "#{prop}=#{val}"]
c7b72c
   flags = ['--force']
c7b72c
+  sig_file = "#{CIB_PATH}.sig"
c7b72c
+  retcode = 0
c7b72c
+
c7b72c
   if pacemaker_running?
c7b72c
-    user = auth_user
c7b72c
+    _, _, retcode = run_cmd(auth_user, PCS, *flags, "--", *cmd)
c7b72c
   else
c7b72c
-    user = PCSAuth.getSuperuserAuth()
c7b72c
-    flags += ['-f', CIB_PATH]
c7b72c
+    if File.exist?(CIB_PATH)
c7b72c
+      flags += ['-f', CIB_PATH]
c7b72c
+      _, _, retcode = run_cmd(PCSAuth.getSuperuserAuth(), PCS, *flags, "--", *cmd)
c7b72c
+      begin
c7b72c
+        File.delete(sig_file)
c7b72c
+      rescue => e
c7b72c
+        $logger.debug("Cannot delete file '#{sig_file}': #{e.message}")
c7b72c
+      end
c7b72c
+    end
c7b72c
   end
c7b72c
-    _, _, retcode = run_cmd(user, PCS, *flags, "--", *cmd)
c7b72c
   return (retcode == 0)
c7b72c
 end
c7b72c
 
c7b72c
-- 
c7b72c
2.39.0
c7b72c