From 95775fa7a99017dcd3d7ce5e29ab3a282b73004f643c82b78d4ef6d4bec3d900 Mon Sep 17 00:00:00 2001 From: Victor Zhestkov Date: Thu, 17 Oct 2024 14:25:02 +0000 Subject: [PATCH] - Handle logger exception when flushing already closed file - Include passlib as a recommended dependency - Added: * handle-logger-flushing-already-closed-file-686.patch OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=263 --- _lastrevision | 2 +- ...ger-flushing-already-closed-file-686.patch | 58 +++++++++++++++++++ salt.changes | 9 +++ salt.spec | 3 + 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 handle-logger-flushing-already-closed-file-686.patch diff --git a/_lastrevision b/_lastrevision index 4baeeee..804a09e 100644 --- a/_lastrevision +++ b/_lastrevision @@ -1 +1 @@ -af4efe8013e54de4be818761003c5966c88b6c19 \ No newline at end of file +e1eca529a18f7fde5ceec0e3d9524028c7affd12 \ No newline at end of file diff --git a/handle-logger-flushing-already-closed-file-686.patch b/handle-logger-flushing-already-closed-file-686.patch new file mode 100644 index 0000000..558bcdb --- /dev/null +++ b/handle-logger-flushing-already-closed-file-686.patch @@ -0,0 +1,58 @@ +From e23dce108588a9c52d3f7542636892750d6efcbd Mon Sep 17 00:00:00 2001 +From: Marek Czernek +Date: Thu, 17 Oct 2024 15:52:00 +0200 +Subject: [PATCH] Handle logger flushing already closed file (#686) + +This is a partial cherry-pick of +https://github.com/saltstack/salt/commit/9683260d61668da8559ecde6caf63a52fedd8790 +--- + salt/_logging/handlers.py | 4 ++++ + salt/_logging/impl.py | 10 +++++++++- + 2 files changed, 13 insertions(+), 1 deletion(-) + +diff --git a/salt/_logging/handlers.py b/salt/_logging/handlers.py +index 5a1a1613137..d8bc68a49db 100644 +--- a/salt/_logging/handlers.py ++++ b/salt/_logging/handlers.py +@@ -95,6 +95,9 @@ class DeferredStreamHandler(StreamHandler): + super().__init__(stream) + self.__messages = deque(maxlen=max_queue_size) + self.__emitting = False ++ import traceback ++ ++ self.stack = "".join(traceback.format_stack()) + + def handle(self, record): + self.acquire() +@@ -116,6 +119,7 @@ class DeferredStreamHandler(StreamHandler): + super().handle(record) + finally: + self.__emitting = False ++ # This will raise a ValueError if the file handle has been closed. + super().flush() + + def sync_with_handlers(self, handlers=()): +diff --git a/salt/_logging/impl.py b/salt/_logging/impl.py +index 4d1ebd2495f..9d76c3174e2 100644 +--- a/salt/_logging/impl.py ++++ b/salt/_logging/impl.py +@@ -488,7 +488,15 @@ def setup_temp_handler(log_level=None): + break + else: + handler = DeferredStreamHandler(sys.stderr) +- atexit.register(handler.flush) ++ ++ def tryflush(): ++ try: ++ handler.flush() ++ except ValueError: ++ # File handle has already been closed. ++ pass ++ ++ atexit.register(tryflush) + handler.setLevel(log_level) + + # Set the default temporary console formatter config +-- +2.47.0 + diff --git a/salt.changes b/salt.changes index eb34bad..35b9df8 100644 --- a/salt.changes +++ b/salt.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Thu Oct 17 14:02:57 UTC 2024 - Marek Czernek + +- Handle logger exception when flushing already closed file +- Include passlib as a recommended dependency + +- Added: + * handle-logger-flushing-already-closed-file-686.patch + ------------------------------------------------------------------- Thu Oct 10 11:19:52 UTC 2024 - Pablo Suárez Hernández diff --git a/salt.spec b/salt.spec index b93b560..312e30e 100644 --- a/salt.spec +++ b/salt.spec @@ -452,6 +452,8 @@ Patch143: fix-x509-test-fails-on-old-openssl-systems-682.patch Patch144: fix-x509-private-key-tests-and-test_suse-on-sle12-68.patch # PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/685 Patch145: enhance-cleanup-mechanism-after-salt-bundle-upgrade-.patch +# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/commit/9683260d61668da8559ecde6caf63a52fedd8790 +Patch146: handle-logger-flushing-already-closed-file-686.patch ### IMPORTANT: The line below is used as a snippet marker. Do not touch it. ### SALT PATCHES LIST END @@ -649,6 +651,7 @@ Requires: iputils Requires: sudo Requires: file Recommends: man +Recommends: python3-passlib Provides: bundled(python3-tornado) = 4.5.3