- 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
This commit is contained in:
Victor Zhestkov 2024-10-17 14:25:02 +00:00 committed by Git OBS Bridge
parent 4c35e9d114
commit 95775fa7a9
4 changed files with 71 additions and 1 deletions

View File

@ -1 +1 @@
af4efe8013e54de4be818761003c5966c88b6c19
e1eca529a18f7fde5ceec0e3d9524028c7affd12

View File

@ -0,0 +1,58 @@
From e23dce108588a9c52d3f7542636892750d6efcbd Mon Sep 17 00:00:00 2001
From: Marek Czernek <marek.czernek@suse.com>
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

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Thu Oct 17 14:02:57 UTC 2024 - Marek Czernek <marek.czernek@suse.com>
- 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 <psuarezhernandez@suse.com>

View File

@ -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