Resolves: rhbz#2026725 rhbz#2058243

- Fixed booth ticket mode value case insensitive
- Fixed booth sync check whether /etc/booth exists
This commit is contained in:
Miroslav Lisik 2022-07-28 15:43:31 +02:00
parent a6938416c6
commit c06ed2a4ad
4 changed files with 2675 additions and 1 deletions

View File

@ -0,0 +1,46 @@
From f863c38497eb716141c9e585ddb418191e9fc2a4 Mon Sep 17 00:00:00 2001
From: Tomas Jelinek <tojeline@redhat.com>
Date: Fri, 15 Jul 2022 15:55:57 +0200
Subject: [PATCH 3/3] booth sync: check whether /etc/booth exists
---
pcsd/pcsd_file.rb | 6 +-----
pcsd/remote.rb | 4 ++++
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/pcsd/pcsd_file.rb b/pcsd/pcsd_file.rb
index d82b55d2..394db59a 100644
--- a/pcsd/pcsd_file.rb
+++ b/pcsd/pcsd_file.rb
@@ -112,12 +112,8 @@ module PcsdFile
end
end
- def dir()
- return BOOTH_CONFIG_DIR
- end
-
def full_file_name()
- @full_file_name ||= File.join(self.dir, @file[:name])
+ @full_file_name ||= File.join(BOOTH_CONFIG_DIR, @file[:name])
end
end
diff --git a/pcsd/remote.rb b/pcsd/remote.rb
index 854674eb..144d25f3 100644
--- a/pcsd/remote.rb
+++ b/pcsd/remote.rb
@@ -2090,6 +2090,10 @@ def booth_set_config(params, request, auth_user)
check_permissions(auth_user, Permissions::WRITE)
data = check_request_data_for_json(params, auth_user)
+ if not File.directory?(BOOTH_CONFIG_DIR)
+ raise "Configuration directory for booth '/etc/booth' is missing. Is booth installed?"
+ end
+
PcsdExchangeFormat::validate_item_map_is_Hash('files', data)
PcsdExchangeFormat::validate_item_is_Hash('file', :config, data[:config])
if data[:authfile]
--
2.35.3

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,126 @@
From de4845ea2d22c7dd9f4539360b44a900b1cea193 Mon Sep 17 00:00:00 2001
From: Tomas Jelinek <tojeline@redhat.com>
Date: Thu, 14 Jul 2022 16:46:33 +0200
Subject: [PATCH 2/3] make booth ticket mode value case insensitive
---
pcs/lib/booth/config_validators.py | 10 ++++++++
pcs/lib/commands/booth.py | 14 +++++++++---
pcs_test/tier0/lib/commands/test_booth.py | 28 ++++++++++++++++-------
3 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/pcs/lib/booth/config_validators.py b/pcs/lib/booth/config_validators.py
index 99badc46..6c4a4ddc 100644
--- a/pcs/lib/booth/config_validators.py
+++ b/pcs/lib/booth/config_validators.py
@@ -100,6 +100,16 @@ def remove_ticket(conf_facade, ticket_name):
return []
+def ticket_options_normalization() -> validate.TypeNormalizeFunc:
+ return validate.option_value_normalization(
+ {
+ "mode": (
+ lambda value: value.lower() if isinstance(value, str) else value
+ )
+ }
+ )
+
+
def validate_ticket_name(ticket_name: str) -> reports.ReportItemList:
if not __TICKET_NAME_RE.search(ticket_name):
return [
diff --git a/pcs/lib/commands/booth.py b/pcs/lib/commands/booth.py
index e7891fbe..fc1454ce 100644
--- a/pcs/lib/commands/booth.py
+++ b/pcs/lib/commands/booth.py
@@ -23,7 +23,10 @@ from pcs.common.reports.item import (
)
from pcs.common.services.errors import ManageServiceError
from pcs.common.str_tools import join_multilines
-from pcs.lib import tools
+from pcs.lib import (
+ tools,
+ validate,
+)
from pcs.lib.booth import (
config_files,
config_validators,
@@ -329,17 +332,22 @@ def config_ticket_add(
booth_env = env.get_booth_env(instance_name)
try:
booth_conf = booth_env.config.read_to_facade()
+ options_pairs = validate.values_to_pairs(
+ options, config_validators.ticket_options_normalization()
+ )
report_processor.report_list(
config_validators.add_ticket(
booth_conf,
ticket_name,
- options,
+ options_pairs,
allow_unknown_options=allow_unknown_options,
)
)
if report_processor.has_errors:
raise LibraryError()
- booth_conf.add_ticket(ticket_name, options)
+ booth_conf.add_ticket(
+ ticket_name, validate.pairs_to_values(options_pairs)
+ )
booth_env.config.write_facade(booth_conf, can_overwrite=True)
except RawFileError as e:
report_processor.report(raw_file_error_report(e))
diff --git a/pcs_test/tier0/lib/commands/test_booth.py b/pcs_test/tier0/lib/commands/test_booth.py
index 2b20a199..12b169c2 100644
--- a/pcs_test/tier0/lib/commands/test_booth.py
+++ b/pcs_test/tier0/lib/commands/test_booth.py
@@ -1194,7 +1194,7 @@ class ConfigTicketAdd(TestCase, FixtureMixin):
},
)
- def test_success_ticket_options(self):
+ def assert_success_ticket_options(self, options_command, options_config):
self.config.raw_file.read(
file_type_codes.BOOTH_CONFIG,
self.fixture_cfg_path(),
@@ -1203,17 +1203,29 @@ class ConfigTicketAdd(TestCase, FixtureMixin):
self.config.raw_file.write(
file_type_codes.BOOTH_CONFIG,
self.fixture_cfg_path(),
- self.fixture_cfg_content(
- ticket_list=[
- ["ticketA", [("retries", "10"), ("timeout", "20")]]
- ]
- ),
+ self.fixture_cfg_content(ticket_list=[["ticketA", options_config]]),
can_overwrite=True,
)
commands.config_ticket_add(
- self.env_assist.get_env(),
- "ticketA",
+ self.env_assist.get_env(), "ticketA", options_command
+ )
+
+ def test_success_ticket_options(self):
+ self.assert_success_ticket_options(
{"timeout": "20", "retries": "10"},
+ [("retries", "10"), ("timeout", "20")],
+ )
+
+ def test_success_ticket_options_mode(self):
+ self.assert_success_ticket_options(
+ {"timeout": "20", "retries": "10", "mode": "manual"},
+ [("mode", "manual"), ("retries", "10"), ("timeout", "20")],
+ )
+
+ def test_success_ticket_options_mode_case_insensitive(self):
+ self.assert_success_ticket_options(
+ {"timeout": "20", "retries": "10", "mode": "MaNuAl"},
+ [("mode", "manual"), ("retries", "10"), ("timeout", "20")],
)
def test_ticket_already_exists(self):
--
2.35.3

View File

@ -1,6 +1,6 @@
Name: pcs
Version: 0.11.3
Release: 2%{?dist}
Release: 3%{?dist}
# https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/
# https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Good_Licenses
# GPLv2: pcs
@ -111,6 +111,9 @@ Source101: https://github.com/ClusterLabs/pcs-web-ui/releases/download/%{ui_comm
# pcs patches: <= 200
Patch1: do-not-support-cluster-setup-with-udp-u-transport.patch
Patch2: bz2102663-01-fix-pcs-resource-restart-traceback.patch
Patch3: bz2058243-01-code-formatting.patch
Patch4: bz2058243-02-make-booth-ticket-mode-value-case-insensitive.patch
Patch5: bz2026725-01-booth-sync-check-whether-etc-booth-exists.patch
# ui patches: >200
# Patch201: bzNUMBER-01-name.patch
@ -296,6 +299,9 @@ update_times_patch(){
%autopatch -p1 -M 200
update_times_patch %{PATCH1}
update_times_patch %{PATCH2}
update_times_patch %{PATCH3}
update_times_patch %{PATCH4}
update_times_patch %{PATCH5}
# prepare dirs/files necessary for building all bundles
# -----------------------------------------------------
@ -533,6 +539,11 @@ run_all_tests
%license pyagentx_LICENSE.txt
%changelog
* Thu Jul 28 2022 Miroslav Lisik <mlisik@redhat.com> - 0.11.3-3
- Fixed booth ticket mode value case insensitive
- Fixed booth sync check whether /etc/booth exists
- Resolves: rhbz#2026725 rhbz#2058243
* Tue Jul 12 2022 Miroslav Lisik <mlisik@redhat.com> - 0.11.3-2
- Fixed 'pcs resource restart' traceback
- Resolves: rhbz#2102663