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

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