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

3362d5
From 3cd35ed8e5b190c2e8203acd68a0100b84ed3bb4 Mon Sep 17 00:00:00 2001
3362d5
From: Ondrej Mular <omular@redhat.com>
3362d5
Date: Tue, 31 Jan 2023 17:44:16 +0100
3362d5
Subject: [PATCH] fix update of stonith-watchdog-timeout when cluster is not
3362d5
 running
3362d5
3362d5
---
3362d5
 pcs/lib/communication/sbd.py                  |  4 +-
3362d5
 .../lib/commands/sbd/test_disable_sbd.py      | 10 ++--
3362d5
 .../tier0/lib/commands/sbd/test_enable_sbd.py | 49 ++++++++++---------
3362d5
 pcsd/pcs.rb                                   | 17 +++++--
3362d5
 4 files changed, 48 insertions(+), 32 deletions(-)
3362d5
3362d5
diff --git a/pcs/lib/communication/sbd.py b/pcs/lib/communication/sbd.py
3362d5
index 4762245c..633312a4 100644
3362d5
--- a/pcs/lib/communication/sbd.py
3362d5
+++ b/pcs/lib/communication/sbd.py
3362d5
@@ -98,8 +98,8 @@ class StonithWatchdogTimeoutAction(
3362d5
         )
3362d5
         if report_item is None:
3362d5
             self._on_success()
3362d5
-            return []
3362d5
-        self._report(report_item)
3362d5
+        else:
3362d5
+            self._report(report_item)
3362d5
         return self._get_next_list()
3362d5
 
3362d5
 
3362d5
diff --git a/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py b/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py
3362d5
index 13135fb2..f8f165bf 100644
3362d5
--- a/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py
3362d5
+++ b/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py
3362d5
@@ -19,7 +19,7 @@ class DisableSbd(TestCase):
3362d5
         self.config.corosync_conf.load(filename=self.corosync_conf_name)
3362d5
         self.config.http.host.check_auth(node_labels=self.node_list)
3362d5
         self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero(
3362d5
-            node_labels=self.node_list[:1]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.disable_sbd(node_labels=self.node_list)
3362d5
         disable_sbd(self.env_assist.get_env())
3362d5
@@ -56,7 +56,7 @@ class DisableSbd(TestCase):
3362d5
         self.config.corosync_conf.load(filename=self.corosync_conf_name)
3362d5
         self.config.http.host.check_auth(node_labels=self.node_list)
3362d5
         self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero(
3362d5
-            node_labels=self.node_list[:1]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.disable_sbd(node_labels=self.node_list)
3362d5
 
3362d5
@@ -158,7 +158,9 @@ class DisableSbd(TestCase):
3362d5
             ]
3362d5
         )
3362d5
         self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero(
3362d5
-            node_labels=online_nodes_list[:1]
3362d5
+            communication_list=[
3362d5
+                [dict(label=node)] for node in self.node_list[1:]
3362d5
+            ],
3362d5
         )
3362d5
         self.config.http.sbd.disable_sbd(node_labels=online_nodes_list)
3362d5
         disable_sbd(self.env_assist.get_env(), ignore_offline_nodes=True)
3362d5
@@ -291,7 +293,7 @@ class DisableSbd(TestCase):
3362d5
         self.config.corosync_conf.load(filename=self.corosync_conf_name)
3362d5
         self.config.http.host.check_auth(node_labels=self.node_list)
3362d5
         self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero(
3362d5
-            node_labels=self.node_list[:1]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.disable_sbd(
3362d5
             communication_list=[
3362d5
diff --git a/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py b/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py
3362d5
index 57e680e0..f192f429 100644
3362d5
--- a/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py
3362d5
+++ b/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py
3362d5
@@ -130,7 +130,7 @@ class OddNumOfNodesSuccess(TestCase):
3362d5
             node_labels=self.node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.node_list[0]]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
3362d5
         enable_sbd(
3362d5
@@ -164,7 +164,7 @@ class OddNumOfNodesSuccess(TestCase):
3362d5
             node_labels=self.node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.node_list[0]]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
3362d5
         enable_sbd(
3362d5
@@ -218,7 +218,7 @@ class OddNumOfNodesDefaultsSuccess(TestCase):
3362d5
             node_labels=self.node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.node_list[0]]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
3362d5
         enable_sbd(
3362d5
@@ -248,7 +248,7 @@ class OddNumOfNodesDefaultsSuccess(TestCase):
3362d5
             node_labels=self.node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.node_list[0]]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
3362d5
         enable_sbd(
3362d5
@@ -351,7 +351,7 @@ class WatchdogValidations(TestCase):
3362d5
             node_labels=self.node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.node_list[0]]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
3362d5
         enable_sbd(
3362d5
@@ -407,7 +407,7 @@ class EvenNumOfNodes(TestCase):
3362d5
             node_labels=self.node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.node_list[0]]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
3362d5
         enable_sbd(
3362d5
@@ -443,7 +443,7 @@ class EvenNumOfNodes(TestCase):
3362d5
             node_labels=self.node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.node_list[0]]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
3362d5
         enable_sbd(
3362d5
@@ -480,7 +480,7 @@ class EvenNumOfNodes(TestCase):
3362d5
             node_labels=self.node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.node_list[0]]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
3362d5
         enable_sbd(
3362d5
@@ -513,7 +513,7 @@ class EvenNumOfNodes(TestCase):
3362d5
             node_labels=self.node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.node_list[0]]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.node_list)
3362d5
         enable_sbd(
3362d5
@@ -604,7 +604,9 @@ class OfflineNodes(TestCase):
3362d5
             node_labels=self.online_node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.online_node_list[0]]
3362d5
+            communication_list=[
3362d5
+                [dict(label=node)] for node in self.online_node_list
3362d5
+            ],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.online_node_list)
3362d5
         enable_sbd(
3362d5
@@ -644,7 +646,9 @@ class OfflineNodes(TestCase):
3362d5
             node_labels=self.online_node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.online_node_list[0]]
3362d5
+            communication_list=[
3362d5
+                [dict(label=node)] for node in self.online_node_list
3362d5
+            ],
3362d5
         )
3362d5
         self.config.http.sbd.enable_sbd(node_labels=self.online_node_list)
3362d5
         enable_sbd(
3362d5
@@ -1226,7 +1230,7 @@ class FailureHandling(TestCase):
3362d5
             node_labels=self.node_list,
3362d5
         )
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
-            node_labels=[self.node_list[0]]
3362d5
+            communication_list=[[dict(label=node)] for node in self.node_list],
3362d5
         )
3362d5
 
3362d5
     def _remove_calls(self, count):
3362d5
@@ -1302,7 +1306,8 @@ class FailureHandling(TestCase):
3362d5
         )
3362d5
 
3362d5
     def test_removing_stonith_wd_timeout_failure(self):
3362d5
-        self._remove_calls(2)
3362d5
+        self._remove_calls(len(self.node_list) + 1)
3362d5
+
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
             communication_list=[
3362d5
                 self.communication_list_failure[:1],
3362d5
@@ -1331,7 +1336,7 @@ class FailureHandling(TestCase):
3362d5
         )
3362d5
 
3362d5
     def test_removing_stonith_wd_timeout_not_connected(self):
3362d5
-        self._remove_calls(2)
3362d5
+        self._remove_calls(len(self.node_list) + 1)
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
             communication_list=[
3362d5
                 self.communication_list_not_connected[:1],
3362d5
@@ -1360,7 +1365,7 @@ class FailureHandling(TestCase):
3362d5
         )
3362d5
 
3362d5
     def test_removing_stonith_wd_timeout_complete_failure(self):
3362d5
-        self._remove_calls(2)
3362d5
+        self._remove_calls(len(self.node_list) + 1)
3362d5
         self.config.http.pcmk.remove_stonith_watchdog_timeout(
3362d5
             communication_list=[
3362d5
                 self.communication_list_not_connected[:1],
3362d5
@@ -1406,7 +1411,7 @@ class FailureHandling(TestCase):
3362d5
         )
3362d5
 
3362d5
     def test_set_sbd_config_failure(self):
3362d5
-        self._remove_calls(4)
3362d5
+        self._remove_calls(len(self.node_list) + 1 + 2)
3362d5
         self.config.http.sbd.set_sbd_config(
3362d5
             communication_list=[
3362d5
                 dict(
3362d5
@@ -1453,7 +1458,7 @@ class FailureHandling(TestCase):
3362d5
         )
3362d5
 
3362d5
     def test_set_corosync_conf_failed(self):
3362d5
-        self._remove_calls(5)
3362d5
+        self._remove_calls(len(self.node_list) + 1 + 3)
3362d5
         self.config.env.push_corosync_conf(
3362d5
             corosync_conf_text=_get_corosync_conf_text_with_atb(
3362d5
                 self.corosync_conf_name
3362d5
@@ -1477,7 +1482,7 @@ class FailureHandling(TestCase):
3362d5
         )
3362d5
 
3362d5
     def test_check_sbd_invalid_data_format(self):
3362d5
-        self._remove_calls(7)
3362d5
+        self._remove_calls(len(self.node_list) + 1 + 5)
3362d5
         self.config.http.sbd.check_sbd(
3362d5
             communication_list=[
3362d5
                 dict(
3362d5
@@ -1516,7 +1521,7 @@ class FailureHandling(TestCase):
3362d5
         )
3362d5
 
3362d5
     def test_check_sbd_failure(self):
3362d5
-        self._remove_calls(7)
3362d5
+        self._remove_calls(len(self.node_list) + 1 + 5)
3362d5
         self.config.http.sbd.check_sbd(
3362d5
             communication_list=[
3362d5
                 dict(
3362d5
@@ -1558,7 +1563,7 @@ class FailureHandling(TestCase):
3362d5
         )
3362d5
 
3362d5
     def test_check_sbd_not_connected(self):
3362d5
-        self._remove_calls(7)
3362d5
+        self._remove_calls(len(self.node_list) + 1 + 5)
3362d5
         self.config.http.sbd.check_sbd(
3362d5
             communication_list=[
3362d5
                 dict(
3362d5
@@ -1601,7 +1606,7 @@ class FailureHandling(TestCase):
3362d5
         )
3362d5
 
3362d5
     def test_get_online_targets_failed(self):
3362d5
-        self._remove_calls(9)
3362d5
+        self._remove_calls(len(self.node_list) + 1 + 7)
3362d5
         self.config.http.host.check_auth(
3362d5
             communication_list=self.communication_list_failure
3362d5
         )
3362d5
@@ -1626,7 +1631,7 @@ class FailureHandling(TestCase):
3362d5
         )
3362d5
 
3362d5
     def test_get_online_targets_not_connected(self):
3362d5
-        self._remove_calls(9)
3362d5
+        self._remove_calls(len(self.node_list) + 1 + 7)
3362d5
         self.config.http.host.check_auth(
3362d5
             communication_list=self.communication_list_not_connected
3362d5
         )
3362d5
diff --git a/pcsd/pcs.rb b/pcsd/pcs.rb
3362d5
index 452de97f..e3397c25 100644
3362d5
--- a/pcsd/pcs.rb
3362d5
+++ b/pcsd/pcs.rb
3362d5
@@ -1838,13 +1838,22 @@ end
3362d5
 def set_cluster_prop_force(auth_user, prop, val)
3362d5
   cmd = ['property', 'set', "#{prop}=#{val}"]
3362d5
   flags = ['--force']
3362d5
+  sig_file = "#{CIB_PATH}.sig"
3362d5
+  retcode = 0
3362d5
+
3362d5
   if pacemaker_running?
3362d5
-    user = auth_user
3362d5
+    _, _, retcode = run_cmd(auth_user, PCS, *flags, "--", *cmd)
3362d5
   else
3362d5
-    user = PCSAuth.getSuperuserAuth()
3362d5
-    flags += ['-f', CIB_PATH]
3362d5
+    if File.exist?(CIB_PATH)
3362d5
+      flags += ['-f', CIB_PATH]
3362d5
+      _, _, retcode = run_cmd(PCSAuth.getSuperuserAuth(), PCS, *flags, "--", *cmd)
3362d5
+      begin
3362d5
+        File.delete(sig_file)
3362d5
+      rescue => e
3362d5
+        $logger.debug("Cannot delete file '#{sig_file}': #{e.message}")
3362d5
+      end
3362d5
+    end
3362d5
   end
3362d5
-    _, _, retcode = run_cmd(user, PCS, *flags, "--", *cmd)
3362d5
   return (retcode == 0)
3362d5
 end
3362d5
 
3362d5
-- 
3362d5
2.39.0
3362d5