diff --git a/backport-fix-logging-handlers-imports.patch b/backport-fix-logging-handlers-imports.patch new file mode 100644 index 0000000000000000000000000000000000000000..a13b07f4d9535bf15dc3bfb5f951b481215d2527 --- /dev/null +++ b/backport-fix-logging-handlers-imports.patch @@ -0,0 +1,40 @@ +From 1fa3faf5afde712abd4362fd80b148e363bc3c84 Mon Sep 17 00:00:00 2001 +From: Miroslav Lisik +Date: Fri, 22 Mar 2024 15:01:19 +0100 +Subject: [PATCH] fix logging handlers imports + +* https://stackoverflow.com/questions/64951836/python-logging-attributeerror-module-logging-has-no-attribute-handlers/65814814#65814814 +--- + pcs/daemon/async_tasks/worker/logging.py | 3 ++- + pcs/daemon/log.py | 1 + + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/pcs/daemon/async_tasks/worker/logging.py b/pcs/daemon/async_tasks/worker/logging.py +index cf5fb2872..1319d6512 100644 +--- a/pcs/daemon/async_tasks/worker/logging.py ++++ b/pcs/daemon/async_tasks/worker/logging.py +@@ -1,4 +1,5 @@ + import logging ++import logging.handlers + import multiprocessing as mp + import os + +@@ -44,7 +45,7 @@ def setup_worker_logger(queue: mp.Queue) -> logging.Logger: + logger = logging.getLogger(WORKER_LOGGER) + logger.setLevel(logging.DEBUG) + +- queue_handler = logging.handlers.QueueHandler(queue) # type: ignore ++ queue_handler = logging.handlers.QueueHandler(queue) + logger.addHandler(queue_handler) + + return logger +diff --git a/pcs/daemon/log.py b/pcs/daemon/log.py +index 07ca764a9..a38cbbdf0 100644 +--- a/pcs/daemon/log.py ++++ b/pcs/daemon/log.py +@@ -1,4 +1,5 @@ + import logging ++import logging.handlers + + LOGGER_NAMES = [ + "pcs.daemon", diff --git a/backport-fix-running-pcsd-from-git.patch b/backport-fix-running-pcsd-from-git.patch new file mode 100644 index 0000000000000000000000000000000000000000..fe47189aaec257949b17fe243f471c59c2a4b560 --- /dev/null +++ b/backport-fix-running-pcsd-from-git.patch @@ -0,0 +1,70 @@ +From 14dde17cb8c13df047cc2b840e9f8244522d986d Mon Sep 17 00:00:00 2001 +From: Miroslav Lisik +Date: Thu, 25 Apr 2024 13:41:16 +0200 +Subject: [PATCH] fix running pcsd from git + +* has been broken since fork method change to forkserver +--- + pcs/pcs.in | 47 ++++++++++++++++++++++++----------------------- + 1 file changed, 24 insertions(+), 23 deletions(-) + +diff --git a/pcs/pcs.in b/pcs/pcs.in +index d0fcd775d..09c637e9a 100755 +--- a/pcs/pcs.in ++++ b/pcs/pcs.in +@@ -2,31 +2,32 @@ + import os.path + import sys + +-CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) ++if __name__ == "__main__": ++ CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) + +-# We prevent to import some module from this dir instead of e.g. standard module. +-# There is no reason to import anything from this module. +-sys.path.remove(CURRENT_DIR) ++ # We prevent to import some module from this dir instead of e.g. standard module. ++ # There is no reason to import anything from this module. ++ sys.path.remove(CURRENT_DIR) + +-# Add pcs package. +-PACKAGE_DIR = os.path.dirname(CURRENT_DIR) +-BUNDLED_PACKAGES_DIR = os.path.join(PACKAGE_DIR, "@PCS_BUNDLED_DIR_LOCAL@", "packages") +-sys.path.insert(0, BUNDLED_PACKAGES_DIR) +-sys.path.insert(0, PACKAGE_DIR) ++ # Add pcs package. ++ PACKAGE_DIR = os.path.dirname(CURRENT_DIR) ++ BUNDLED_PACKAGES_DIR = os.path.join(PACKAGE_DIR, "@PCS_BUNDLED_DIR_LOCAL@", "packages") ++ sys.path.insert(0, BUNDLED_PACKAGES_DIR) ++ sys.path.insert(0, PACKAGE_DIR) + +-# pylint: disable=wrong-import-position +-# we need settings to be imported from a path defined above +-from pcs import settings ++ # pylint: disable=wrong-import-position ++ # we need settings to be imported from a path defined above ++ from pcs import settings + +-settings.pcsd_exec_location = os.path.join(PACKAGE_DIR, "pcsd") +-settings.pcsd_gem_path = os.path.join(PACKAGE_DIR, "@PCSD_BUNDLED_DIR_ROOT_LOCAL@") +-settings.pcs_data_dir = os.path.join(PACKAGE_DIR, "data") ++ settings.pcsd_exec_location = os.path.join(PACKAGE_DIR, "pcsd") ++ settings.pcsd_gem_path = os.path.join(PACKAGE_DIR, "@PCSD_BUNDLED_DIR_ROOT_LOCAL@") ++ settings.pcs_data_dir = os.path.join(PACKAGE_DIR, "data") + +-if "-d" in sys.argv: +- from pcs.daemon.run import main +- argv = sys.argv[:] +- argv.remove("-d") +- main(argv[1:]) +-else: +- from pcs import app +- app.main(sys.argv[1:]) ++ if "-d" in sys.argv: ++ from pcs.daemon.run import main ++ argv = sys.argv[:] ++ argv.remove("-d") ++ main(argv[1:]) ++ else: ++ from pcs import app ++ app.main(sys.argv[1:]) diff --git a/backport-use-ruby-code-instead-of-system-binaries.patch b/backport-use-ruby-code-instead-of-system-binaries.patch new file mode 100644 index 0000000000000000000000000000000000000000..e423206ea0e217fead7128453138927112a3b091 --- /dev/null +++ b/backport-use-ruby-code-instead-of-system-binaries.patch @@ -0,0 +1,44 @@ +From dd317b5fa731f1b4b4fe5f038a919cf5a1eda530 Mon Sep 17 00:00:00 2001 +From: Miroslav Lisik +Date: Wed, 10 Apr 2024 19:11:20 +0200 +Subject: [PATCH] use ruby code instead of system binaries + +* avoid issue with hardcoded paths to system binaries: hostname, cat +--- + pcsd/bootstrap.rb | 3 ++- + pcsd/pcs.rb | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/pcsd/bootstrap.rb b/pcsd/bootstrap.rb +index 6afe0412a..161adcc48 100644 +--- a/pcsd/bootstrap.rb ++++ b/pcsd/bootstrap.rb +@@ -1,5 +1,6 @@ + require 'logger' + require 'pathname' ++require 'socket' + require 'stringio' + + require 'settings.rb' +@@ -46,7 +47,7 @@ def get_pcs_internal_path() + COROSYNC_QUORUMTOOL = File.join(COROSYNC_BINARIES, "corosync-quorumtool") + + if not defined? $cur_node_name +- $cur_node_name = `/bin/hostname`.chomp ++ $cur_node_name = Socket.gethostname + end + + if ENV['PCSD_RESTART_AFTER_REQUESTS'] +diff --git a/pcsd/pcs.rb b/pcsd/pcs.rb +index 119eb27e1..ffc0d3554 100644 +--- a/pcsd/pcs.rb ++++ b/pcsd/pcs.rb +@@ -1435,7 +1435,7 @@ def cluster_status_from_nodes(auth_user, cluster_nodes, cluster_name) + end + + def get_node_uptime() +- uptime = `/bin/cat /proc/uptime`.chomp.split(' ')[0].split('.')[0].to_i ++ uptime = IO.read('/proc/uptime').chomp.split(' ')[0].split('.')[0].to_i + mm, ss = uptime.divmod(60) + hh, mm = mm.divmod(60) + dd, hh = hh.divmod(24) diff --git a/pcs.spec b/pcs.spec index 107b5e415d2744141d559741b6a5ee17907aa39e..da701bd22e362c85aa8cfffe9a807c6b92fd0d75 100644 --- a/pcs.spec +++ b/pcs.spec @@ -1,6 +1,6 @@ Name: pcs Version: 0.11.7 -Release: 15 +Release: 16 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 @@ -50,6 +50,9 @@ Patch10: improve-CPU-usage-when-running-tests-in-parallel.patch Patch11: modernize-validator-of-resources-for-constraints.patch Patch12: fix-mocking-sbd-config-in-quorum-update-tests.patch Patch13: rule-move-top-level-score-responsibility-to-caller.patch +Patch14: backport-fix-logging-handlers-imports.patch +Patch15: backport-use-ruby-code-instead-of-system-binaries.patch +Patch16: backport-fix-running-pcsd-from-git.patch # ui patches: >200 # Patch201: bzNUMBER-01-name.patch @@ -410,6 +413,11 @@ run_all_tests %license pyagentx_LICENSE.txt %changelog +* Mon Aug 19 2024 zhangxingrong - 0.11.7-16 +- fix logging handlers imports +- use ruby code instead of system binaries +- fix running pcsd from git + * Mon Jul 29 2024 zhangxianting - 0.11.7-15 - fix build error