fix booth destroy for arbitrators
This commit is contained in:
parent
690590cbdd
commit
1171a7f6b1
@ -45,8 +45,8 @@ index 1ce5a2a5..de39b3a5 100644
|
|||||||
+ "to 2023-12-31T12:00';\n"
|
+ "to 2023-12-31T12:00';\n"
|
||||||
"pcs -- constraint rule add location-R1 \\\n"
|
"pcs -- constraint rule add location-R1 \\\n"
|
||||||
" id=location-R1-rule-1 score=INFINITY \\\n"
|
" id=location-R1-rule-1 score=INFINITY \\\n"
|
||||||
- " '#uname' eq node2 and date gt 2023-01-01T12:00 and "
|
- " '#uname' eq node1 and date gt 2023-01-01T12:00 and "
|
||||||
+ " '#uname eq node2 and date gt 2023-01-01T12:00 and "
|
+ " '#uname eq node1 and date gt 2023-01-01T12:00 and "
|
||||||
"date lt 2023-12-31T12:00 and date in_range 2023-01-01T12:00 "
|
"date lt 2023-12-31T12:00 and date in_range 2023-01-01T12:00 "
|
||||||
- "to 2023-12-31T12:00\n"
|
- "to 2023-12-31T12:00\n"
|
||||||
+ "to 2023-12-31T12:00'\n"
|
+ "to 2023-12-31T12:00'\n"
|
||||||
|
|||||||
243
backport-fix-booth-destroy-for-arbitrators.patch
Normal file
243
backport-fix-booth-destroy-for-arbitrators.patch
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
From af9510afb3ce53b3dd05136fdbb9f0a5cc048205 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Jelinek <tojeline@redhat.com>
|
||||||
|
Date: Fri, 31 May 2024 16:00:06 +0200
|
||||||
|
Subject: [PATCH] fix booth destroy for arbitrators
|
||||||
|
|
||||||
|
---
|
||||||
|
pcs/lib/commands/booth.py | 35 ++++---
|
||||||
|
pcs/lib/pacemaker/live.py | 4 +
|
||||||
|
pcs_test/tier0/lib/commands/test_booth.py | 110 ++++++++++++++++++++--
|
||||||
|
3 files changed, 129 insertions(+), 20 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pcs/lib/commands/booth.py b/pcs/lib/commands/booth.py
|
||||||
|
index c961705b..f291a085 100644
|
||||||
|
--- a/pcs/lib/commands/booth.py
|
||||||
|
+++ b/pcs/lib/commands/booth.py
|
||||||
|
@@ -58,6 +58,7 @@ from pcs.lib.file.raw_file import (
|
||||||
|
)
|
||||||
|
from pcs.lib.interface.config import ParserErrorException
|
||||||
|
from pcs.lib.node import get_existing_nodes_names
|
||||||
|
+from pcs.lib.pacemaker.live import has_cib_xml
|
||||||
|
from pcs.lib.resource_agent import (
|
||||||
|
ResourceAgentError,
|
||||||
|
ResourceAgentFacade,
|
||||||
|
@@ -165,20 +166,30 @@ def config_destroy(
|
||||||
|
found_instance_name = booth_env.instance_name
|
||||||
|
_ensure_live_env(env, booth_env)
|
||||||
|
|
||||||
|
- booth_resource_list = resource.find_for_config(
|
||||||
|
- get_resources(env.get_cib()),
|
||||||
|
- booth_env.config_path,
|
||||||
|
- )
|
||||||
|
- if booth_resource_list:
|
||||||
|
- report_processor.report(
|
||||||
|
- ReportItem.error(
|
||||||
|
- reports.messages.BoothConfigIsUsed(
|
||||||
|
- found_instance_name,
|
||||||
|
- reports.const.BOOTH_CONFIG_USED_IN_CLUSTER_RESOURCE,
|
||||||
|
- resource_name=str(booth_resource_list[0].get("id", "")),
|
||||||
|
+ if (
|
||||||
|
+ has_cib_xml()
|
||||||
|
+ or env.service_manager.is_running("pacemaker")
|
||||||
|
+ or env.service_manager.is_running("pacemaker_remoted")
|
||||||
|
+ ):
|
||||||
|
+ # To allow destroying booth config on arbitrators, only check CIB if:
|
||||||
|
+ # * pacemaker is running and therefore we are able to get CIB
|
||||||
|
+ # * CIB is stored on disk - pcmk is not running but the node is in a
|
||||||
|
+ # cluster (don't checking corosync to cover remote and guest nodes)
|
||||||
|
+ # If CIB cannot be loaded in either case, fail with an error.
|
||||||
|
+ booth_resource_list = resource.find_for_config(
|
||||||
|
+ get_resources(env.get_cib()),
|
||||||
|
+ booth_env.config_path,
|
||||||
|
+ )
|
||||||
|
+ if booth_resource_list:
|
||||||
|
+ report_processor.report(
|
||||||
|
+ ReportItem.error(
|
||||||
|
+ reports.messages.BoothConfigIsUsed(
|
||||||
|
+ found_instance_name,
|
||||||
|
+ reports.const.BOOTH_CONFIG_USED_IN_CLUSTER_RESOURCE,
|
||||||
|
+ resource_name=str(booth_resource_list[0].get("id", "")),
|
||||||
|
+ )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
- )
|
||||||
|
# Only systemd is currently supported. Initd does not supports multiple
|
||||||
|
# instances (here specified by name)
|
||||||
|
if is_systemd(env.service_manager):
|
||||||
|
diff --git a/pcs/lib/pacemaker/live.py b/pcs/lib/pacemaker/live.py
|
||||||
|
index 301ce343..43197ac1 100644
|
||||||
|
--- a/pcs/lib/pacemaker/live.py
|
||||||
|
+++ b/pcs/lib/pacemaker/live.py
|
||||||
|
@@ -151,6 +151,10 @@ def get_ticket_status_text(runner: CommandRunner) -> Tuple[str, str, int]:
|
||||||
|
### cib
|
||||||
|
|
||||||
|
|
||||||
|
+def has_cib_xml() -> bool:
|
||||||
|
+ return os.path.exists(os.path.join(settings.cib_dir, "cib.xml"))
|
||||||
|
+
|
||||||
|
+
|
||||||
|
def get_cib_xml_cmd_results(
|
||||||
|
runner: CommandRunner, scope: Optional[str] = None
|
||||||
|
) -> tuple[str, str, int]:
|
||||||
|
diff --git a/pcs_test/tier0/lib/commands/test_booth.py b/pcs_test/tier0/lib/commands/test_booth.py
|
||||||
|
index 4e945216..2957e378 100644
|
||||||
|
--- a/pcs_test/tier0/lib/commands/test_booth.py
|
||||||
|
+++ b/pcs_test/tier0/lib/commands/test_booth.py
|
||||||
|
@@ -524,10 +524,13 @@ class ConfigSetupAuthfileFix(TestCase, FixtureMixin):
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigDestroy(TestCase, FixtureMixin):
|
||||||
|
+ # pylint: disable=too-many-public-methods
|
||||||
|
def setUp(self):
|
||||||
|
self.env_assist, self.config = get_env_tools(self)
|
||||||
|
+ self.cib_path = os.path.join(settings.cib_dir, "cib.xml")
|
||||||
|
|
||||||
|
def fixture_config_booth_not_used(self, instance_name="booth"):
|
||||||
|
+ self.config.fs.exists(self.cib_path, True)
|
||||||
|
self.config.runner.cib.load()
|
||||||
|
self.config.services.is_running(
|
||||||
|
"booth", instance=instance_name, return_value=False
|
||||||
|
@@ -536,6 +539,44 @@ class ConfigDestroy(TestCase, FixtureMixin):
|
||||||
|
"booth", instance=instance_name, return_value=False
|
||||||
|
)
|
||||||
|
|
||||||
|
+ def fixture_config_booth_used(
|
||||||
|
+ self,
|
||||||
|
+ instance_name,
|
||||||
|
+ cib_exists=False,
|
||||||
|
+ pcmk_running=False,
|
||||||
|
+ pcmk_remote_running=False,
|
||||||
|
+ booth_running=False,
|
||||||
|
+ booth_enabled=False,
|
||||||
|
+ ):
|
||||||
|
+ cib_load_exception = False
|
||||||
|
+ self.config.fs.exists(self.cib_path, cib_exists)
|
||||||
|
+ if not cib_exists:
|
||||||
|
+ self.config.services.is_running(
|
||||||
|
+ "pacemaker",
|
||||||
|
+ return_value=pcmk_running,
|
||||||
|
+ name="services.is_running.pcmk",
|
||||||
|
+ )
|
||||||
|
+ if not pcmk_running:
|
||||||
|
+ self.config.services.is_running(
|
||||||
|
+ "pacemaker_remoted",
|
||||||
|
+ return_value=pcmk_remote_running,
|
||||||
|
+ name="services.is_running.pcmk_remote",
|
||||||
|
+ )
|
||||||
|
+ if cib_exists and not pcmk_running and not pcmk_remote_running:
|
||||||
|
+ self.config.runner.cib.load(
|
||||||
|
+ returncode=1, stderr="unable to get cib, pcmk is not running"
|
||||||
|
+ )
|
||||||
|
+ cib_load_exception = True
|
||||||
|
+ elif pcmk_running or pcmk_remote_running:
|
||||||
|
+ self.config.runner.cib.load(resources=self.fixture_cib_resources())
|
||||||
|
+ if not cib_load_exception:
|
||||||
|
+ self.config.services.is_running(
|
||||||
|
+ "booth", instance=instance_name, return_value=booth_running
|
||||||
|
+ )
|
||||||
|
+ self.config.services.is_enabled(
|
||||||
|
+ "booth", instance=instance_name, return_value=booth_enabled
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
def fixture_config_success(self, instance_name="booth"):
|
||||||
|
self.fixture_config_booth_not_used(instance_name)
|
||||||
|
self.config.raw_file.read(
|
||||||
|
@@ -663,17 +704,29 @@ class ConfigDestroy(TestCase, FixtureMixin):
|
||||||
|
expected_in_processor=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
- def test_booth_config_in_use(self):
|
||||||
|
+ def test_booth_config_in_use_cib_pcmk(self):
|
||||||
|
instance_name = "booth"
|
||||||
|
+ self.fixture_config_booth_used(instance_name, pcmk_running=True)
|
||||||
|
|
||||||
|
- self.config.runner.cib.load(resources=self.fixture_cib_resources())
|
||||||
|
- self.config.services.is_running(
|
||||||
|
- "booth", instance=instance_name, return_value=True
|
||||||
|
+ self.env_assist.assert_raise_library_error(
|
||||||
|
+ lambda: commands.config_destroy(self.env_assist.get_env()),
|
||||||
|
)
|
||||||
|
- self.config.services.is_enabled(
|
||||||
|
- "booth", instance=instance_name, return_value=True
|
||||||
|
+
|
||||||
|
+ self.env_assist.assert_reports(
|
||||||
|
+ [
|
||||||
|
+ fixture.error(
|
||||||
|
+ reports.codes.BOOTH_CONFIG_IS_USED,
|
||||||
|
+ name=instance_name,
|
||||||
|
+ detail=reports.const.BOOTH_CONFIG_USED_IN_CLUSTER_RESOURCE,
|
||||||
|
+ resource_name="booth_resource",
|
||||||
|
+ ),
|
||||||
|
+ ]
|
||||||
|
)
|
||||||
|
|
||||||
|
+ def test_booth_config_in_use_cib_pcmk_remote(self):
|
||||||
|
+ instance_name = "booth"
|
||||||
|
+ self.fixture_config_booth_used(instance_name, pcmk_remote_running=True)
|
||||||
|
+
|
||||||
|
self.env_assist.assert_raise_library_error(
|
||||||
|
lambda: commands.config_destroy(self.env_assist.get_env()),
|
||||||
|
)
|
||||||
|
@@ -686,16 +739,57 @@ class ConfigDestroy(TestCase, FixtureMixin):
|
||||||
|
detail=reports.const.BOOTH_CONFIG_USED_IN_CLUSTER_RESOURCE,
|
||||||
|
resource_name="booth_resource",
|
||||||
|
),
|
||||||
|
+ ]
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ def test_pcmk_not_running(self):
|
||||||
|
+ instance_name = "booth"
|
||||||
|
+ self.fixture_config_booth_used(instance_name, cib_exists=True)
|
||||||
|
+
|
||||||
|
+ self.env_assist.assert_raise_library_error(
|
||||||
|
+ lambda: commands.config_destroy(self.env_assist.get_env()),
|
||||||
|
+ [
|
||||||
|
+ fixture.error(
|
||||||
|
+ reports.codes.CIB_LOAD_ERROR,
|
||||||
|
+ reason="unable to get cib, pcmk is not running",
|
||||||
|
+ )
|
||||||
|
+ ],
|
||||||
|
+ expected_in_processor=False,
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ def test_booth_config_in_use_systemd_running(self):
|
||||||
|
+ instance_name = "booth"
|
||||||
|
+ self.fixture_config_booth_used(instance_name, booth_running=True)
|
||||||
|
+
|
||||||
|
+ self.env_assist.assert_raise_library_error(
|
||||||
|
+ lambda: commands.config_destroy(self.env_assist.get_env()),
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ self.env_assist.assert_reports(
|
||||||
|
+ [
|
||||||
|
fixture.error(
|
||||||
|
reports.codes.BOOTH_CONFIG_IS_USED,
|
||||||
|
name=instance_name,
|
||||||
|
- detail=reports.const.BOOTH_CONFIG_USED_ENABLED_IN_SYSTEMD,
|
||||||
|
+ detail=reports.const.BOOTH_CONFIG_USED_RUNNING_IN_SYSTEMD,
|
||||||
|
resource_name=None,
|
||||||
|
),
|
||||||
|
+ ]
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ def test_booth_config_in_use_systemd_enabled(self):
|
||||||
|
+ instance_name = "booth"
|
||||||
|
+ self.fixture_config_booth_used(instance_name, booth_enabled=True)
|
||||||
|
+
|
||||||
|
+ self.env_assist.assert_raise_library_error(
|
||||||
|
+ lambda: commands.config_destroy(self.env_assist.get_env()),
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ self.env_assist.assert_reports(
|
||||||
|
+ [
|
||||||
|
fixture.error(
|
||||||
|
reports.codes.BOOTH_CONFIG_IS_USED,
|
||||||
|
name=instance_name,
|
||||||
|
- detail=reports.const.BOOTH_CONFIG_USED_RUNNING_IN_SYSTEMD,
|
||||||
|
+ detail=reports.const.BOOTH_CONFIG_USED_ENABLED_IN_SYSTEMD,
|
||||||
|
resource_name=None,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
12
pcs.spec
12
pcs.spec
@ -1,6 +1,6 @@
|
|||||||
Name: pcs
|
Name: pcs
|
||||||
Version: 0.11.7
|
Version: 0.11.7
|
||||||
Release: 14
|
Release: 15
|
||||||
License: GPL-2.0-only AND Apache-2.0 AND MIT AND BSD-3-Clause AND (BSD-2-Clause OR Ruby) AND (BSD-2-Clause OR GPL-2.0-or-later)
|
License: GPL-2.0-only AND Apache-2.0 AND MIT AND BSD-3-Clause AND (BSD-2-Clause OR Ruby) AND (BSD-2-Clause OR GPL-2.0-or-later)
|
||||||
URL: https://github.com/ClusterLabs/pcs
|
URL: https://github.com/ClusterLabs/pcs
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
@ -45,9 +45,10 @@ Patch5: update-crm_mon-schemas-for-tests.patch
|
|||||||
Patch6: add-dtos-and-converting-functions-for-resources-stat.patch
|
Patch6: add-dtos-and-converting-functions-for-resources-stat.patch
|
||||||
Patch7: fixes-after-review.patch
|
Patch7: fixes-after-review.patch
|
||||||
Patch8: store-clone-instance-id-in-resource-status-dtos.patch
|
Patch8: store-clone-instance-id-in-resource-status-dtos.patch
|
||||||
Patch9: increase-a-timeout-in-a-test.patch
|
Patch9: increase-a-timeout-in-a-test.patch
|
||||||
Patch10: backport-fix-stdout-wrapping-to-terminal-width.patch
|
Patch10: Export-rule-constraints-in-a-non-deprecated-way.patch
|
||||||
|
Patch11: backport-fix-stdout-wrapping-to-terminal-width.patch
|
||||||
|
Patch12: backport-fix-booth-destroy-for-arbitrators.patch
|
||||||
# ui patches: >200
|
# ui patches: >200
|
||||||
# Patch201: bzNUMBER-01-name.patch
|
# Patch201: bzNUMBER-01-name.patch
|
||||||
|
|
||||||
@ -408,6 +409,9 @@ run_all_tests
|
|||||||
%license pyagentx_LICENSE.txt
|
%license pyagentx_LICENSE.txt
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Sep 02 2024 zouzhimin <zouzhimin@kylinos.cn> - 0.11.7-15
|
||||||
|
- fix booth destroy for arbitrators
|
||||||
|
|
||||||
* Wed May 29 2024 zouzhimin <zouzhimin@kylinos.cn> - 0.11.7-14
|
* Wed May 29 2024 zouzhimin <zouzhimin@kylinos.cn> - 0.11.7-14
|
||||||
- fix stdout wrapping to terminal width and modify spec file, sed command to replace "patch3" with "patch1"
|
- fix stdout wrapping to terminal width and modify spec file, sed command to replace "patch3" with "patch1"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user