diff --git a/SOURCES/bz2166243-01-fix-stonith-watchdog-timeout-offline-update.patch b/SOURCES/bz2166243-01-fix-stonith-watchdog-timeout-offline-update.patch new file mode 100644 index 0000000..b388333 --- /dev/null +++ b/SOURCES/bz2166243-01-fix-stonith-watchdog-timeout-offline-update.patch @@ -0,0 +1,311 @@ +From 3cd35ed8e5b190c2e8203acd68a0100b84ed3bb4 Mon Sep 17 00:00:00 2001 +From: Ondrej Mular +Date: Tue, 31 Jan 2023 17:44:16 +0100 +Subject: [PATCH] fix update of stonith-watchdog-timeout when cluster is not + running + +--- + pcs/lib/communication/sbd.py | 4 +- + .../lib/commands/sbd/test_disable_sbd.py | 10 ++-- + .../tier0/lib/commands/sbd/test_enable_sbd.py | 49 ++++++++++--------- + pcsd/pcs.rb | 17 +++++-- + 4 files changed, 48 insertions(+), 32 deletions(-) + +diff --git a/pcs/lib/communication/sbd.py b/pcs/lib/communication/sbd.py +index 4762245c..633312a4 100644 +--- a/pcs/lib/communication/sbd.py ++++ b/pcs/lib/communication/sbd.py +@@ -98,8 +98,8 @@ class StonithWatchdogTimeoutAction( + ) + if report_item is None: + self._on_success() +- return [] +- self._report(report_item) ++ else: ++ self._report(report_item) + return self._get_next_list() + + +diff --git a/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py b/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py +index 13135fb2..f8f165bf 100644 +--- a/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py ++++ b/pcs_test/tier0/lib/commands/sbd/test_disable_sbd.py +@@ -19,7 +19,7 @@ class DisableSbd(TestCase): + self.config.corosync_conf.load(filename=self.corosync_conf_name) + self.config.http.host.check_auth(node_labels=self.node_list) + self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero( +- node_labels=self.node_list[:1] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.disable_sbd(node_labels=self.node_list) + disable_sbd(self.env_assist.get_env()) +@@ -56,7 +56,7 @@ class DisableSbd(TestCase): + self.config.corosync_conf.load(filename=self.corosync_conf_name) + self.config.http.host.check_auth(node_labels=self.node_list) + self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero( +- node_labels=self.node_list[:1] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.disable_sbd(node_labels=self.node_list) + +@@ -158,7 +158,9 @@ class DisableSbd(TestCase): + ] + ) + self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero( +- node_labels=online_nodes_list[:1] ++ communication_list=[ ++ [dict(label=node)] for node in self.node_list[1:] ++ ], + ) + self.config.http.sbd.disable_sbd(node_labels=online_nodes_list) + disable_sbd(self.env_assist.get_env(), ignore_offline_nodes=True) +@@ -291,7 +293,7 @@ class DisableSbd(TestCase): + self.config.corosync_conf.load(filename=self.corosync_conf_name) + self.config.http.host.check_auth(node_labels=self.node_list) + self.config.http.pcmk.set_stonith_watchdog_timeout_to_zero( +- node_labels=self.node_list[:1] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.disable_sbd( + communication_list=[ +diff --git a/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py b/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py +index 57e680e0..f192f429 100644 +--- a/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py ++++ b/pcs_test/tier0/lib/commands/sbd/test_enable_sbd.py +@@ -130,7 +130,7 @@ class OddNumOfNodesSuccess(TestCase): + node_labels=self.node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.node_list[0]] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.enable_sbd(node_labels=self.node_list) + enable_sbd( +@@ -164,7 +164,7 @@ class OddNumOfNodesSuccess(TestCase): + node_labels=self.node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.node_list[0]] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.enable_sbd(node_labels=self.node_list) + enable_sbd( +@@ -218,7 +218,7 @@ class OddNumOfNodesDefaultsSuccess(TestCase): + node_labels=self.node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.node_list[0]] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.enable_sbd(node_labels=self.node_list) + enable_sbd( +@@ -248,7 +248,7 @@ class OddNumOfNodesDefaultsSuccess(TestCase): + node_labels=self.node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.node_list[0]] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.enable_sbd(node_labels=self.node_list) + enable_sbd( +@@ -351,7 +351,7 @@ class WatchdogValidations(TestCase): + node_labels=self.node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.node_list[0]] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.enable_sbd(node_labels=self.node_list) + enable_sbd( +@@ -407,7 +407,7 @@ class EvenNumOfNodes(TestCase): + node_labels=self.node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.node_list[0]] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.enable_sbd(node_labels=self.node_list) + enable_sbd( +@@ -443,7 +443,7 @@ class EvenNumOfNodes(TestCase): + node_labels=self.node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.node_list[0]] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.enable_sbd(node_labels=self.node_list) + enable_sbd( +@@ -480,7 +480,7 @@ class EvenNumOfNodes(TestCase): + node_labels=self.node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.node_list[0]] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.enable_sbd(node_labels=self.node_list) + enable_sbd( +@@ -513,7 +513,7 @@ class EvenNumOfNodes(TestCase): + node_labels=self.node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.node_list[0]] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + self.config.http.sbd.enable_sbd(node_labels=self.node_list) + enable_sbd( +@@ -604,7 +604,9 @@ class OfflineNodes(TestCase): + node_labels=self.online_node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.online_node_list[0]] ++ communication_list=[ ++ [dict(label=node)] for node in self.online_node_list ++ ], + ) + self.config.http.sbd.enable_sbd(node_labels=self.online_node_list) + enable_sbd( +@@ -644,7 +646,9 @@ class OfflineNodes(TestCase): + node_labels=self.online_node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.online_node_list[0]] ++ communication_list=[ ++ [dict(label=node)] for node in self.online_node_list ++ ], + ) + self.config.http.sbd.enable_sbd(node_labels=self.online_node_list) + enable_sbd( +@@ -1226,7 +1230,7 @@ class FailureHandling(TestCase): + node_labels=self.node_list, + ) + self.config.http.pcmk.remove_stonith_watchdog_timeout( +- node_labels=[self.node_list[0]] ++ communication_list=[[dict(label=node)] for node in self.node_list], + ) + + def _remove_calls(self, count): +@@ -1302,7 +1306,8 @@ class FailureHandling(TestCase): + ) + + def test_removing_stonith_wd_timeout_failure(self): +- self._remove_calls(2) ++ self._remove_calls(len(self.node_list) + 1) ++ + self.config.http.pcmk.remove_stonith_watchdog_timeout( + communication_list=[ + self.communication_list_failure[:1], +@@ -1331,7 +1336,7 @@ class FailureHandling(TestCase): + ) + + def test_removing_stonith_wd_timeout_not_connected(self): +- self._remove_calls(2) ++ self._remove_calls(len(self.node_list) + 1) + self.config.http.pcmk.remove_stonith_watchdog_timeout( + communication_list=[ + self.communication_list_not_connected[:1], +@@ -1360,7 +1365,7 @@ class FailureHandling(TestCase): + ) + + def test_removing_stonith_wd_timeout_complete_failure(self): +- self._remove_calls(2) ++ self._remove_calls(len(self.node_list) + 1) + self.config.http.pcmk.remove_stonith_watchdog_timeout( + communication_list=[ + self.communication_list_not_connected[:1], +@@ -1406,7 +1411,7 @@ class FailureHandling(TestCase): + ) + + def test_set_sbd_config_failure(self): +- self._remove_calls(4) ++ self._remove_calls(len(self.node_list) + 1 + 2) + self.config.http.sbd.set_sbd_config( + communication_list=[ + dict( +@@ -1453,7 +1458,7 @@ class FailureHandling(TestCase): + ) + + def test_set_corosync_conf_failed(self): +- self._remove_calls(5) ++ self._remove_calls(len(self.node_list) + 1 + 3) + self.config.env.push_corosync_conf( + corosync_conf_text=_get_corosync_conf_text_with_atb( + self.corosync_conf_name +@@ -1477,7 +1482,7 @@ class FailureHandling(TestCase): + ) + + def test_check_sbd_invalid_data_format(self): +- self._remove_calls(7) ++ self._remove_calls(len(self.node_list) + 1 + 5) + self.config.http.sbd.check_sbd( + communication_list=[ + dict( +@@ -1516,7 +1521,7 @@ class FailureHandling(TestCase): + ) + + def test_check_sbd_failure(self): +- self._remove_calls(7) ++ self._remove_calls(len(self.node_list) + 1 + 5) + self.config.http.sbd.check_sbd( + communication_list=[ + dict( +@@ -1558,7 +1563,7 @@ class FailureHandling(TestCase): + ) + + def test_check_sbd_not_connected(self): +- self._remove_calls(7) ++ self._remove_calls(len(self.node_list) + 1 + 5) + self.config.http.sbd.check_sbd( + communication_list=[ + dict( +@@ -1601,7 +1606,7 @@ class FailureHandling(TestCase): + ) + + def test_get_online_targets_failed(self): +- self._remove_calls(9) ++ self._remove_calls(len(self.node_list) + 1 + 7) + self.config.http.host.check_auth( + communication_list=self.communication_list_failure + ) +@@ -1626,7 +1631,7 @@ class FailureHandling(TestCase): + ) + + def test_get_online_targets_not_connected(self): +- self._remove_calls(9) ++ self._remove_calls(len(self.node_list) + 1 + 7) + self.config.http.host.check_auth( + communication_list=self.communication_list_not_connected + ) +diff --git a/pcsd/pcs.rb b/pcsd/pcs.rb +index 452de97f..e3397c25 100644 +--- a/pcsd/pcs.rb ++++ b/pcsd/pcs.rb +@@ -1838,13 +1838,22 @@ end + def set_cluster_prop_force(auth_user, prop, val) + cmd = ['property', 'set', "#{prop}=#{val}"] + flags = ['--force'] ++ sig_file = "#{CIB_PATH}.sig" ++ retcode = 0 ++ + if pacemaker_running? +- user = auth_user ++ _, _, retcode = run_cmd(auth_user, PCS, *flags, "--", *cmd) + else +- user = PCSAuth.getSuperuserAuth() +- flags += ['-f', CIB_PATH] ++ if File.exist?(CIB_PATH) ++ flags += ['-f', CIB_PATH] ++ _, _, retcode = run_cmd(PCSAuth.getSuperuserAuth(), PCS, *flags, "--", *cmd) ++ begin ++ File.delete(sig_file) ++ rescue => e ++ $logger.debug("Cannot delete file '#{sig_file}': #{e.message}") ++ end ++ end + end +- _, _, retcode = run_cmd(user, PCS, *flags, "--", *cmd) + return (retcode == 0) + end + +-- +2.39.0 + diff --git a/SPECS/pcs.spec b/SPECS/pcs.spec index 96dcd42..4a78f2c 100644 --- a/SPECS/pcs.spec +++ b/SPECS/pcs.spec @@ -1,6 +1,6 @@ Name: pcs Version: 0.10.15 -Release: 3%{?dist} +Release: 4%{?dist} # https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/ # https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Good_Licenses # GPL-2.0-only: pcs @@ -127,6 +127,7 @@ Patch3: bz2151166-01-fix-displaying-bool-and-integer-values.patch Patch4: pcsd-rubygem-json-error-message-change.patch Patch5: bz2159455-01-add-agent-validation-option.patch Patch6: bz2158804-01-fix-stonith-watchdog-timeout-validation.patch +Patch7: bz2166243-01-fix-stonith-watchdog-timeout-offline-update.patch # Downstream patches do not come from upstream. They adapt pcs for specific # RHEL needs. @@ -165,6 +166,10 @@ BuildRequires: rubygem-test-unit BuildRequires: diffstat # for post, preun and postun macros BuildRequires: systemd +# pam is used for authentication inside daemon (python ctypes) +# needed for tier0 tests during build +BuildRequires: pam + # pcsd fonts and font management tools for creating symlinks to fonts BuildRequires: fontconfig BuildRequires: liberation-sans-fonts @@ -331,6 +336,7 @@ update_times_patch %{PATCH3} update_times_patch %{PATCH4} update_times_patch %{PATCH5} update_times_patch %{PATCH6} +update_times_patch %{PATCH7} # update_times_patch %{PATCH101} @@ -583,6 +589,11 @@ remove_all_tests %license pyagentx_LICENSE.txt %changelog +* Thu Feb 9 2023 Michal Pospisil - 0.10.15-4 +- Fixed enabling/disabling sbd when cluster is not running +- Added BuildRequires: pam - needed for tier0 tests during build +- Resolves: rhbz#2166243 + * Mon Jan 16 2023 Michal Pospisil - 0.10.15-3 - Allow time values in stonith-watchdog-time property - Resource/stonith agent self-validation of instance attributes is now disabled by default, as many agents do not work with it properly