Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
43fee466d1
!92 修复pcs booth destroy命令
From: @xiangbudaomz 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2024-09-02 07:47:52 +00:00
zouzhimin
1171a7f6b1 fix booth destroy for arbitrators 2024-08-01 12:35:51 +08:00
openeuler-ci-bot
690590cbdd
!81 fix stdout wrapping to terminal width and modify spec file, sed command to replace patch3 with patch1
From: @xiangbudaomz 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2024-06-06 09:06:01 +00:00
openeuler-ci-bot
5b177a3977
!80 fix: Support for other distributions and delete -S git from %autosetup
From: @xiangbudaomz 
Reviewed-by: @bixiaoyan1, @linfong 
Signed-off-by: @bixiaoyan1, @linfong
2024-05-13 09:50:39 +00:00
openeuler-ci-bot
03a1ceef6f
!78 export rule constraints in a non-deprecated way
From: @bixiaoyan1 
Reviewed-by: @xiangbudaomz 
Signed-off-by: @xiangbudaomz
2024-05-11 08:45:41 +00:00
bixiaoyan
044696c383 export rule constraints in a non-deprecated way 2024-05-11 16:25:59 +08:00
zouzhimin
fa152eb018 fix stdout wrapping to terminal width and modify spec file, sed command to replace patch3 with patch1 2024-04-29 23:29:03 +08:00
zouzhimin
6a91cbeed7 fix: Support for other distributions and delete -S git from %autosetup 2024-04-29 16:55:57 +08:00
openeuler-ci-bot
7e652e5cb3
!76 increase a timeout in a test
From: @bizhiyuan 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2024-04-24 11:40:36 +00:00
bizhiyuan
92c3ababee increase a timeout in a test 2024-04-24 10:22:50 +08:00
5 changed files with 403 additions and 6 deletions

View File

@ -0,0 +1,58 @@
From 4d375004dd11b7ddc4dd3f211c06008d71626dcf Mon Sep 17 00:00:00 2001
From: Tomas Jelinek <tojeline@redhat.com>
Date: Tue, 30 Apr 2024 15:31:06 +0200
Subject: [PATCH] export rule constraints in a non-deprecated way
---
pcs/cli/constraint/output/location.py | 4 ++--
pcs_test/tier1/constraint/test_config.py | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/pcs/cli/constraint/output/location.py b/pcs/cli/constraint/output/location.py
index 25ac646a..141959d5 100644
--- a/pcs/cli/constraint/output/location.py
+++ b/pcs/cli/constraint/output/location.py
@@ -190,7 +190,7 @@ def _add_rule_cmd(constraint_id: str, rule: CibRuleExpressionDto) -> list[str]:
indent(
[
pairs_to_cmd([("id", rule.id)] + _rule_to_cmd_pairs(rule)),
- shlex.join(shlex.split(rule.as_string)),
+ shlex.quote(rule.as_string),
],
indent_step=INDENT_STEP,
)
@@ -221,7 +221,7 @@ def _plain_constraint_rule_to_cmd(
+ _attributes_to_pairs(constraint_dto.attributes)
+ _rule_to_cmd_pairs(first_rule)
),
- shlex.join(shlex.split(first_rule.as_string)),
+ shlex.quote(first_rule.as_string),
],
indent_step=INDENT_STEP,
)
diff --git a/pcs_test/tier1/constraint/test_config.py b/pcs_test/tier1/constraint/test_config.py
index 1ce5a2a5..de39b3a5 100644
--- a/pcs_test/tier1/constraint/test_config.py
+++ b/pcs_test/tier1/constraint/test_config.py
@@ -191,14 +191,14 @@ class ConstraintConfigCmdSpaceInDate(ConstraintConfigCmdMixin, TestCase):
(
"pcs -- constraint location resource%R1 rule \\\n"
" id=location-R1-rule constraint-id=location-R1 score=INFINITY \\\n"
- " '#uname' eq node1 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 "
- "to 2023-12-31T12:00;\n"
+ "to 2023-12-31T12:00';\n"
"pcs -- constraint rule add location-R1 \\\n"
" id=location-R1-rule-1 score=INFINITY \\\n"
- " '#uname' eq node1 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 "
- "to 2023-12-31T12:00\n"
+ "to 2023-12-31T12:00'\n"
),
)
--
2.25.1

View 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

View File

@ -0,0 +1,49 @@
From 2f4ebe9dfb2d9854e6ae05834e6062d245dae88d Mon Sep 17 00:00:00 2001
From: Tomas Jelinek <tojeline@redhat.com>
Date: Thu, 16 May 2024 10:36:23 +0200
Subject: [PATCH] fix stdout wrapping to terminal width
---
CHANGELOG.md | 3 +++
pcs/cli/common/output.py | 8 +++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a198d0f7..a6ef6cc2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,9 +7,12 @@
when not specified in `pcs cluster uidgid add` command. Empty options cause
corosync start failure. ([ghissue#772])
- Do not allow fencing levels other than 1..9 ([RHEL-2977])
+- Do not wrap pcs output to terminal width if pcs's stdout is redirected
+ ([RHEL-36514])
[ghissue#772]: https://github.com/ClusterLabs/pcs/issues/772
[RHEL-2977]: https://issues.redhat.com/browse/RHEL-2977
+[RHEL-36514]: https://issues.redhat.com/browse/RHEL-36514
## [0.11.7] - 2024-01-11
diff --git a/pcs/cli/common/output.py b/pcs/cli/common/output.py
index 179f7c03..9dc0e162 100644
--- a/pcs/cli/common/output.py
+++ b/pcs/cli/common/output.py
@@ -56,9 +56,11 @@ def format_wrap_for_terminal(
trim -- number which will be substracted from terminal size. Can be used in
cases lines will be indented later by this number of spaces.
"""
- if (sys.stdout is not None and sys.stdout.isatty()) or (
- sys.stderr is not None and sys.stderr.isatty()
- ):
+ # This function is used for stdout only - we don't care about wrapping
+ # error messages and debug info. So it checks stdout and not stderr.
+ # Checking stderr would enable wrapping in case of 'pcs ... | grep ...'
+ # (stderr is connected to a terminal), which we don't want. (RHEL-36514)
+ if sys.stdout is not None and sys.stdout.isatty():
return format_wrap(
text,
# minimal line length is 40
--
2.25.1

View File

@ -0,0 +1,28 @@
From 78cfa76f7edbe362c152d2ad4ad8e4012a61e437 Mon Sep 17 00:00:00 2001
From: Tomas Jelinek <tojeline@redhat.com>
Date: Wed, 17 Apr 2024 17:25:04 +0200
Subject: [PATCH] increase a timeout in a test
---
pcs_test/tier0/daemon/app/test_app_remote.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/pcs_test/tier0/daemon/app/test_app_remote.py b/pcs_test/tier0/daemon/app/test_app_remote.py
index c6a6b235..dc176846 100644
--- a/pcs_test/tier0/daemon/app/test_app_remote.py
+++ b/pcs_test/tier0/daemon/app/test_app_remote.py
@@ -121,7 +121,10 @@ class SyncConfigMutualExclusive(AppTest):
# Without lock the timeout should be enough to finish task. With the
# lock it should raise because of timeout. The same timeout is used for
# noticing differences between test with and test without lock.
- return self.io_loop.run_sync(fetch_sync_options, timeout=0.5)
+ # The timeout needs to be long enough for the test to fit into it even
+ # if running on a slower machine. And it should be short enough not to
+ # make the test run unnecessary long.
+ return self.io_loop.run_sync(fetch_sync_options, timeout=2.5)
def check_call_wrapper_without_lock(self, method):
self.assert_wrappers_response(self.fetch_set_sync_options(method))
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: pcs
Version: 0.11.7
Release: 10
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)
URL: https://github.com/ClusterLabs/pcs
Group: System Environment/Base
@ -45,12 +45,13 @@ Patch5: update-crm_mon-schemas-for-tests.patch
Patch6: add-dtos-and-converting-functions-for-resources-stat.patch
Patch7: fixes-after-review.patch
Patch8: store-clone-instance-id-in-resource-status-dtos.patch
Patch9: increase-a-timeout-in-a-test.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
# Patch201: bzNUMBER-01-name.patch
# git for patches
BuildRequires: git-core
BuildRequires: make
# printf from coreutils is used in makefile, head is used in spec
BuildRequires: coreutils
@ -186,6 +187,9 @@ Provides: bundled(pyagentx) = %{pyagentx_version}
SNMP agent that provides information about pacemaker cluster to the master agent (snmpd)
%prep
%if "%{_vendor}" != "openEuler"
sed -i 's/openEuler/%{_vendor}/g' %{PATCH1}
%endif
# -- following is inspired by python-simplejon.el5 --
# Update timestamps on the files touched by a patch, to avoid non-equal
@ -230,12 +234,12 @@ update_times_patch(){
# * http://ftp.rpm.org/max-rpm/s1-rpm-inside-macros.html
# * https://rpm-software-management.github.io/rpm/manual/autosetup.html
# patch web-ui sources
%autosetup -D -T -b 3 -a 4 -S git -n %{ui_src_name} -N
%autosetup -D -T -b 3 -a 4 -n %{ui_src_name} -N
%autopatch -p1 -m 201
# update_times_patch %%{PATCH201}
# patch pcs sources
%autosetup -S git -n %{pcs_source_name} -N
%autosetup -n %{pcs_source_name} -N
%autopatch -p1 -m 0
# update_times_patch %%{PATCH0}
update_times_patch %{PATCH0}
@ -405,6 +409,21 @@ run_all_tests
%license pyagentx_LICENSE.txt
%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
- fix stdout wrapping to terminal width and modify spec file, sed command to replace "patch3" with "patch1"
* Mon May 13 2024 zouzhimin <zouzhimin@kylinos.cn> - 0.11.7-13
- fix: Support for other distributions and delete -S git from %autosetup
* Sat May 11 2024 bixiaoyan <bixiaoyan@kylinos.cn> - 0.11.7-12
- export rule constraints in a non-deprecated way
* Wed Apr 24 2024 bizhiyuan <bizhiyuan@kylinos.cn> - 0.11.7-11
- increase a timeout in a test
* Mon Apr 22 2024 laokz <zhangkai@iscas.ac.cn> - 0.11.7-10
- restore setuptools-scm name to adapt setuptools-68.0.0