Skip to content

Commit c1a5aae

Browse files
committed
Revert the change making reactor less blocking (bsc#1230322)
1 parent 87c0b92 commit c1a5aae

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
From c00801d2f9807e49769d0e0d848ec12be555dbc1 Mon Sep 17 00:00:00 2001
2+
From: Victor Zhestkov <[email protected]>
3+
Date: Wed, 25 Sep 2024 14:07:05 +0300
4+
Subject: [PATCH] Revert the change making reactor less blocking
5+
(bsc#1230322)
6+
7+
This reverts commit 0d35f09288700f5c961567442c3fcc25838b8de4.
8+
---
9+
salt/utils/reactor.py | 45 ++++++++++++++++---------------------------
10+
1 file changed, 17 insertions(+), 28 deletions(-)
11+
12+
diff --git a/salt/utils/reactor.py b/salt/utils/reactor.py
13+
index 78adad34da..19420a51cf 100644
14+
--- a/salt/utils/reactor.py
15+
+++ b/salt/utils/reactor.py
16+
@@ -1,12 +1,10 @@
17+
"""
18+
Functions which implement running reactor jobs
19+
"""
20+
-
21+
import fnmatch
22+
import glob
23+
import logging
24+
import os
25+
-from threading import Lock
26+
27+
import salt.client
28+
import salt.defaults.exitcodes
29+
@@ -196,6 +194,13 @@ class Reactor(salt.utils.process.SignalHandlingProcess, salt.state.Compiler):
30+
self.resolve_aliases(chunks)
31+
return chunks
32+
33+
+ def call_reactions(self, chunks):
34+
+ """
35+
+ Execute the reaction state
36+
+ """
37+
+ for chunk in chunks:
38+
+ self.wrap.run(chunk)
39+
+
40+
def run(self):
41+
"""
42+
Enter into the server loop
43+
@@ -213,7 +218,7 @@ class Reactor(salt.utils.process.SignalHandlingProcess, salt.state.Compiler):
44+
) as event:
45+
self.wrap = ReactWrap(self.opts)
46+
47+
- for data in event.iter_events(full=True, auto_reconnect=True):
48+
+ for data in event.iter_events(full=True):
49+
# skip all events fired by ourselves
50+
if data["data"].get("user") == self.wrap.event_user:
51+
continue
52+
@@ -263,9 +268,15 @@ class Reactor(salt.utils.process.SignalHandlingProcess, salt.state.Compiler):
53+
if not self.is_leader:
54+
continue
55+
else:
56+
- self.wrap.call_reactions(
57+
- data, self.list_reactors, self.reactions
58+
- )
59+
+ reactors = self.list_reactors(data["tag"])
60+
+ if not reactors:
61+
+ continue
62+
+ chunks = self.reactions(data["tag"], data["data"], reactors)
63+
+ if chunks:
64+
+ try:
65+
+ self.call_reactions(chunks)
66+
+ except SystemExit:
67+
+ log.warning("Exit ignored by reactor")
68+
69+
70+
class ReactWrap:
71+
@@ -286,7 +297,6 @@ class ReactWrap:
72+
73+
def __init__(self, opts):
74+
self.opts = opts
75+
- self._run_lock = Lock()
76+
if ReactWrap.client_cache is None:
77+
ReactWrap.client_cache = salt.utils.cache.CacheDict(
78+
opts["reactor_refresh_interval"]
79+
@@ -470,24 +480,3 @@ class ReactWrap:
80+
Wrap LocalCaller to execute remote exec functions locally on the Minion
81+
"""
82+
self.client_cache["caller"].cmd(fun, *kwargs["arg"], **kwargs["kwarg"])
83+
-
84+
- def _call_reactions(self, data, list_reactors, get_reactions):
85+
- reactors = list_reactors(data["tag"])
86+
- if not reactors:
87+
- return
88+
- chunks = get_reactions(data["tag"], data["data"], reactors)
89+
- if not chunks:
90+
- return
91+
- with self._run_lock:
92+
- try:
93+
- for chunk in chunks:
94+
- self.run(chunk)
95+
- except Exception as exc: # pylint: disable=broad-except
96+
- log.error(
97+
- "Exception while calling the reactions: %s", exc, exc_info=True
98+
- )
99+
-
100+
- def call_reactions(self, data, list_reactors, get_reactions):
101+
- return self.pool.fire_async(
102+
- self._call_reactions, args=(data, list_reactors, get_reactions)
103+
- )
104+
--
105+
2.46.1
106+

salt/salt.spec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ Patch137: fix-the-selinux-context-for-salt-minion-service-bsc-.patch
440440
Patch138: prevent-using-syncwrapper-with-no-reason.patch
441441
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/66742
442442
Patch139: use-cachedir-for-extension_modules-in-salt-call-bsc-.patch
443+
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/680
444+
Patch140: revert-the-change-making-reactor-less-blocking-bsc-1.patch
443445

444446
### IMPORTANT: The line below is used as a snippet marker. Do not touch it.
445447
### SALT PATCHES LIST END

0 commit comments

Comments
 (0)