- fix logging handlers imports

- Use 'forkserver' process creation method for multiprocessing
This commit is contained in:
eabdullin 2024-07-24 12:20:47 +03:00
parent 1a6763eec6
commit 9dc9761287
3 changed files with 85 additions and 1 deletions

View File

@ -0,0 +1,34 @@
From 2fc4a70cb977b646befa059b99ceabe368f27229 Mon Sep 17 00:00:00 2001
From: Miroslav Lisik <mlisik@redhat.com>
Date: Thu, 21 Mar 2024 13:32:10 +0100
Subject: [PATCH] Use 'forkserver' process creation method for multiprocessing
* 'fork' method could cause deadlock in multiprocessing.pool.Pool on
terminate (https://github.com/python/cpython/issues/73945)
* https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
---
pcs/daemon/run.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/pcs/daemon/run.py b/pcs/daemon/run.py
index 5fa083fd5..cecce750f 100644
--- a/pcs/daemon/run.py
+++ b/pcs/daemon/run.py
@@ -1,3 +1,4 @@
+import multiprocessing as mp
import os
import signal
import socket
@@ -157,6 +158,12 @@ def _print_version(argv: StringCollection) -> None:
def main(argv=None) -> None:
+ # set the way how processes are started
+ # https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
+ # avoid deadlock in multiprocessing.pool.Pool on terminate
+ # https://github.com/python/cpython/issues/73945
+ mp.set_start_method(method="forkserver")
+
argv = argv if argv is not None else sys.argv[1:]
if "--version" in argv:
_print_version(argv)

View File

@ -0,0 +1,40 @@
From 1fa3faf5afde712abd4362fd80b148e363bc3c84 Mon Sep 17 00:00:00 2001
From: Miroslav Lisik <mlisik@redhat.com>
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",

View File

@ -1,6 +1,6 @@
Name: pcs
Version: 0.11.7
Release: 2%{?dist}
Release: 2%{?dist}.1.alma.1
# https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/
# https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Good_Licenses
# GPL-2.0-only: pcs
@ -102,6 +102,12 @@ Source101: https://github.com/ClusterLabs/pcs-web-ui/releases/download/%{ui_comm
# Patch0: bzNUMBER-01-name.patch
Patch0: do-not-support-cluster-setup-with-udp-u-transport.patch
# Patches were taken from:
# https://github.com/ClusterLabs/pcs/commit/2fc4a70cb977b646befa059b99ceabe368f27229
Patch1: Use-forkserver-process-creation-method-for-multiprocessing.patch
# https://github.com/ClusterLabs/pcs/commit/1fa3faf5afde712abd4362fd80b148e363bc3c84
Patch2: fix-logging-handlers-imports.patch
# ui patches: >200
# Patch201: bzNUMBER-01-name.patch
@ -536,6 +542,10 @@ run_all_tests
%license pyagentx_LICENSE.txt
%changelog
* Wed Jul 24 2024 Eduard Abdullin <eabdullin@almalinux.org> - 0.11.7-2.1.alma.1
- fix logging handlers imports
- Use 'forkserver' process creation method for multiprocessing
* Tue Mar 19 2024 Michal Pospisil <mpospisi@redhat.com> - 0.11.7-2
- Fixed CVE-2024-25126, CVE-2024-26141, CVE-2024-26146 in bundled dependency rack
Resolves: RHEL-26446, RHEL-26448, RHEL-26450