Accepting request 1203562 from systemsmanagement:saltstack
OBS-URL: https://build.opensuse.org/request/show/1203562 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/salt?expand=0&rev=160
This commit is contained in:
commit
5f2a7f1e29
@ -1 +1 @@
|
|||||||
89746605096ae1794506d9e1710e82f9efca83ba
|
f52fbbd54dd538b283adddb91e14c9cbdb687060
|
73
allow-namedloadercontexts-to-be-returned-from-loader.patch
Normal file
73
allow-namedloadercontexts-to-be-returned-from-loader.patch
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
From 1be3f92ef3bf14e47340e2e075291204b3e75e98 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Victor Zhestkov <vzhestkov@suse.com>
|
||||||
|
Date: Wed, 25 Sep 2024 14:07:42 +0300
|
||||||
|
Subject: [PATCH] Allow NamedLoaderContexts to be returned from loader
|
||||||
|
|
||||||
|
It is useful in some cases to return NamedLoaderContexts from loaded
|
||||||
|
functions. Instead of choking or requireing implimenters to call the
|
||||||
|
context's value() method before being de-scoped, detect when a
|
||||||
|
NamedLoaderContext has been returned and return the value from the
|
||||||
|
current context.
|
||||||
|
|
||||||
|
Co-authored-by: Daniel A. Wozniak <daniel.wozniak@broadcom.com>
|
||||||
|
---
|
||||||
|
salt/loader/lazy.py | 5 ++++-
|
||||||
|
tests/pytests/integration/modules/test_config.py | 8 ++++++++
|
||||||
|
tests/pytests/unit/loader/test_loader.py | 13 +++++++++++++
|
||||||
|
3 files changed, 25 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100644 tests/pytests/integration/modules/test_config.py
|
||||||
|
|
||||||
|
diff --git a/salt/loader/lazy.py b/salt/loader/lazy.py
|
||||||
|
index 5de995d446..b7fd97f0e1 100644
|
||||||
|
--- a/salt/loader/lazy.py
|
||||||
|
+++ b/salt/loader/lazy.py
|
||||||
|
@@ -1246,7 +1246,10 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
||||||
|
self.parent_loader = current_loader
|
||||||
|
token = salt.loader.context.loader_ctxvar.set(self)
|
||||||
|
try:
|
||||||
|
- return _func_or_method(*args, **kwargs)
|
||||||
|
+ ret = _func_or_method(*args, **kwargs)
|
||||||
|
+ if isinstance(ret, salt.loader.context.NamedLoaderContext):
|
||||||
|
+ ret = ret.value()
|
||||||
|
+ return ret
|
||||||
|
finally:
|
||||||
|
self.parent_loader = None
|
||||||
|
salt.loader.context.loader_ctxvar.reset(token)
|
||||||
|
diff --git a/tests/pytests/integration/modules/test_config.py b/tests/pytests/integration/modules/test_config.py
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..afdf470605
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/tests/pytests/integration/modules/test_config.py
|
||||||
|
@@ -0,0 +1,8 @@
|
||||||
|
+import pytest
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+@pytest.mark.slow_test
|
||||||
|
+def test_config_items(salt_cli, salt_minion):
|
||||||
|
+ ret = salt_cli.run("config.items", minion_tgt=salt_minion.id)
|
||||||
|
+ assert ret.returncode == 0
|
||||||
|
+ assert isinstance(ret.data, dict)
|
||||||
|
diff --git a/tests/pytests/unit/loader/test_loader.py b/tests/pytests/unit/loader/test_loader.py
|
||||||
|
index 86348749db..aba605f42a 100644
|
||||||
|
--- a/tests/pytests/unit/loader/test_loader.py
|
||||||
|
+++ b/tests/pytests/unit/loader/test_loader.py
|
||||||
|
@@ -62,3 +62,16 @@ def test_raw_mod_functions():
|
||||||
|
ret = salt.loader.raw_mod(opts, "grains", "get")
|
||||||
|
for k, v in ret.items():
|
||||||
|
assert isinstance(v, salt.loader.lazy.LoadedFunc)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def test_return_named_context_from_loaded_func(tmp_path):
|
||||||
|
+ opts = {
|
||||||
|
+ "optimization_order": [0],
|
||||||
|
+ }
|
||||||
|
+ contents = """
|
||||||
|
+ def foobar():
|
||||||
|
+ return __test__
|
||||||
|
+ """
|
||||||
|
+ with pytest.helpers.temp_file("mymod.py", contents, directory=tmp_path):
|
||||||
|
+ loader = salt.loader.LazyLoader([tmp_path], opts, pack={"__test__": "meh"})
|
||||||
|
+ assert loader["mymod.foobar"]() == "meh"
|
||||||
|
--
|
||||||
|
2.46.1
|
||||||
|
|
27
avoid-explicit-reading-of-etc-salt-minion-bsc-122035.patch
Normal file
27
avoid-explicit-reading-of-etc-salt-minion-bsc-122035.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
From bbdb56932845dceb47332a4c967c13a9a78b88bc Mon Sep 17 00:00:00 2001
|
||||||
|
From: Victor Zhestkov <vzhestkov@suse.com>
|
||||||
|
Date: Wed, 25 Sep 2024 14:08:20 +0300
|
||||||
|
Subject: [PATCH] Avoid explicit reading of /etc/salt/minion
|
||||||
|
(bsc#1220357)
|
||||||
|
|
||||||
|
Co-authored-by: Daniel A. Wozniak <dwozniak@vmware.com>
|
||||||
|
---
|
||||||
|
salt/utils/azurearm.py | 2 --
|
||||||
|
1 file changed, 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/salt/utils/azurearm.py b/salt/utils/azurearm.py
|
||||||
|
index 276cbb66b3..9ae128273c 100644
|
||||||
|
--- a/salt/utils/azurearm.py
|
||||||
|
+++ b/salt/utils/azurearm.py
|
||||||
|
@@ -47,8 +47,6 @@ try:
|
||||||
|
except ImportError:
|
||||||
|
HAS_AZURE = False
|
||||||
|
|
||||||
|
-__opts__ = salt.config.minion_config("/etc/salt/minion")
|
||||||
|
-__salt__ = salt.loader.minion_mods(__opts__)
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
--
|
||||||
|
2.46.1
|
||||||
|
|
25
prevent-using-syncwrapper-with-no-reason.patch
Normal file
25
prevent-using-syncwrapper-with-no-reason.patch
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
From 936c298c177a50783b080c445745bedf77050cb0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Victor Zhestkov <vzhestkov@suse.com>
|
||||||
|
Date: Wed, 25 Sep 2024 14:04:40 +0300
|
||||||
|
Subject: [PATCH] Prevent using SyncWrapper with no reason
|
||||||
|
|
||||||
|
---
|
||||||
|
salt/channel/server.py | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/salt/channel/server.py b/salt/channel/server.py
|
||||||
|
index b6d51fef08..f1b6f701a9 100644
|
||||||
|
--- a/salt/channel/server.py
|
||||||
|
+++ b/salt/channel/server.py
|
||||||
|
@@ -86,7 +86,7 @@ class ReqServerChannel:
|
||||||
|
# other things needed for _auth
|
||||||
|
# Create the event manager
|
||||||
|
self.event = salt.utils.event.get_master_event(
|
||||||
|
- self.opts, self.opts["sock_dir"], listen=False
|
||||||
|
+ self.opts, self.opts["sock_dir"], listen=False, io_loop=io_loop
|
||||||
|
)
|
||||||
|
self.auto_key = salt.daemons.masterapi.AutoKey(self.opts)
|
||||||
|
# only create a con_cache-client if the con_cache is active
|
||||||
|
--
|
||||||
|
2.46.1
|
||||||
|
|
106
revert-the-change-making-reactor-less-blocking-bsc-1.patch
Normal file
106
revert-the-change-making-reactor-less-blocking-bsc-1.patch
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
From c00801d2f9807e49769d0e0d848ec12be555dbc1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Victor Zhestkov <vzhestkov@suse.com>
|
||||||
|
Date: Wed, 25 Sep 2024 14:07:05 +0300
|
||||||
|
Subject: [PATCH] Revert the change making reactor less blocking
|
||||||
|
(bsc#1230322)
|
||||||
|
|
||||||
|
This reverts commit 0d35f09288700f5c961567442c3fcc25838b8de4.
|
||||||
|
---
|
||||||
|
salt/utils/reactor.py | 45 ++++++++++++++++---------------------------
|
||||||
|
1 file changed, 17 insertions(+), 28 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/salt/utils/reactor.py b/salt/utils/reactor.py
|
||||||
|
index 78adad34da..19420a51cf 100644
|
||||||
|
--- a/salt/utils/reactor.py
|
||||||
|
+++ b/salt/utils/reactor.py
|
||||||
|
@@ -1,12 +1,10 @@
|
||||||
|
"""
|
||||||
|
Functions which implement running reactor jobs
|
||||||
|
"""
|
||||||
|
-
|
||||||
|
import fnmatch
|
||||||
|
import glob
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
-from threading import Lock
|
||||||
|
|
||||||
|
import salt.client
|
||||||
|
import salt.defaults.exitcodes
|
||||||
|
@@ -196,6 +194,13 @@ class Reactor(salt.utils.process.SignalHandlingProcess, salt.state.Compiler):
|
||||||
|
self.resolve_aliases(chunks)
|
||||||
|
return chunks
|
||||||
|
|
||||||
|
+ def call_reactions(self, chunks):
|
||||||
|
+ """
|
||||||
|
+ Execute the reaction state
|
||||||
|
+ """
|
||||||
|
+ for chunk in chunks:
|
||||||
|
+ self.wrap.run(chunk)
|
||||||
|
+
|
||||||
|
def run(self):
|
||||||
|
"""
|
||||||
|
Enter into the server loop
|
||||||
|
@@ -213,7 +218,7 @@ class Reactor(salt.utils.process.SignalHandlingProcess, salt.state.Compiler):
|
||||||
|
) as event:
|
||||||
|
self.wrap = ReactWrap(self.opts)
|
||||||
|
|
||||||
|
- for data in event.iter_events(full=True, auto_reconnect=True):
|
||||||
|
+ for data in event.iter_events(full=True):
|
||||||
|
# skip all events fired by ourselves
|
||||||
|
if data["data"].get("user") == self.wrap.event_user:
|
||||||
|
continue
|
||||||
|
@@ -263,9 +268,15 @@ class Reactor(salt.utils.process.SignalHandlingProcess, salt.state.Compiler):
|
||||||
|
if not self.is_leader:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
- self.wrap.call_reactions(
|
||||||
|
- data, self.list_reactors, self.reactions
|
||||||
|
- )
|
||||||
|
+ reactors = self.list_reactors(data["tag"])
|
||||||
|
+ if not reactors:
|
||||||
|
+ continue
|
||||||
|
+ chunks = self.reactions(data["tag"], data["data"], reactors)
|
||||||
|
+ if chunks:
|
||||||
|
+ try:
|
||||||
|
+ self.call_reactions(chunks)
|
||||||
|
+ except SystemExit:
|
||||||
|
+ log.warning("Exit ignored by reactor")
|
||||||
|
|
||||||
|
|
||||||
|
class ReactWrap:
|
||||||
|
@@ -286,7 +297,6 @@ class ReactWrap:
|
||||||
|
|
||||||
|
def __init__(self, opts):
|
||||||
|
self.opts = opts
|
||||||
|
- self._run_lock = Lock()
|
||||||
|
if ReactWrap.client_cache is None:
|
||||||
|
ReactWrap.client_cache = salt.utils.cache.CacheDict(
|
||||||
|
opts["reactor_refresh_interval"]
|
||||||
|
@@ -470,24 +480,3 @@ class ReactWrap:
|
||||||
|
Wrap LocalCaller to execute remote exec functions locally on the Minion
|
||||||
|
"""
|
||||||
|
self.client_cache["caller"].cmd(fun, *kwargs["arg"], **kwargs["kwarg"])
|
||||||
|
-
|
||||||
|
- def _call_reactions(self, data, list_reactors, get_reactions):
|
||||||
|
- reactors = list_reactors(data["tag"])
|
||||||
|
- if not reactors:
|
||||||
|
- return
|
||||||
|
- chunks = get_reactions(data["tag"], data["data"], reactors)
|
||||||
|
- if not chunks:
|
||||||
|
- return
|
||||||
|
- with self._run_lock:
|
||||||
|
- try:
|
||||||
|
- for chunk in chunks:
|
||||||
|
- self.run(chunk)
|
||||||
|
- except Exception as exc: # pylint: disable=broad-except
|
||||||
|
- log.error(
|
||||||
|
- "Exception while calling the reactions: %s", exc, exc_info=True
|
||||||
|
- )
|
||||||
|
-
|
||||||
|
- def call_reactions(self, data, list_reactors, get_reactions):
|
||||||
|
- return self.pool.fire_async(
|
||||||
|
- self._call_reactions, args=(data, list_reactors, get_reactions)
|
||||||
|
- )
|
||||||
|
--
|
||||||
|
2.46.1
|
||||||
|
|
16
salt.changes
16
salt.changes
@ -1,3 +1,19 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Sep 25 11:45:28 UTC 2024 - Victor Zhestkov <vzhestkov@suse.com>
|
||||||
|
|
||||||
|
- Avoid explicit reading of /etc/salt/minion (bsc#1220357)
|
||||||
|
- Allow NamedLoaderContexts to be returned from loader
|
||||||
|
- Revert the change making reactor less blocking (bsc#1230322)
|
||||||
|
- Use --cachedir for extension_modules in salt-call (bsc#1226141)
|
||||||
|
- Prevent using SyncWrapper with no reason
|
||||||
|
|
||||||
|
- Added:
|
||||||
|
* avoid-explicit-reading-of-etc-salt-minion-bsc-122035.patch
|
||||||
|
* allow-namedloadercontexts-to-be-returned-from-loader.patch
|
||||||
|
* revert-the-change-making-reactor-less-blocking-bsc-1.patch
|
||||||
|
* use-cachedir-for-extension_modules-in-salt-call-bsc-.patch
|
||||||
|
* prevent-using-syncwrapper-with-no-reason.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Sep 10 12:51:43 UTC 2024 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
Tue Sep 10 12:51:43 UTC 2024 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||||
|
|
||||||
|
10
salt.spec
10
salt.spec
@ -436,6 +436,16 @@ Patch135: fix-test_debian-to-work-in-our-infrastructure-676.patch
|
|||||||
Patch136: fix-deprecated-code-677.patch
|
Patch136: fix-deprecated-code-677.patch
|
||||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/66780
|
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/66780
|
||||||
Patch137: fix-the-selinux-context-for-salt-minion-service-bsc-.patch
|
Patch137: fix-the-selinux-context-for-salt-minion-service-bsc-.patch
|
||||||
|
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/66510
|
||||||
|
Patch138: prevent-using-syncwrapper-with-no-reason.patch
|
||||||
|
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/66742
|
||||||
|
Patch139: use-cachedir-for-extension_modules-in-salt-call-bsc-.patch
|
||||||
|
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/680
|
||||||
|
Patch140: revert-the-change-making-reactor-less-blocking-bsc-1.patch
|
||||||
|
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/66649
|
||||||
|
Patch141: allow-namedloadercontexts-to-be-returned-from-loader.patch
|
||||||
|
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/commit/d54407ba6dc664e5e5f3f613e27ae24f828c9648
|
||||||
|
Patch142: avoid-explicit-reading-of-etc-salt-minion-bsc-122035.patch
|
||||||
|
|
||||||
### IMPORTANT: The line below is used as a snippet marker. Do not touch it.
|
### IMPORTANT: The line below is used as a snippet marker. Do not touch it.
|
||||||
### SALT PATCHES LIST END
|
### SALT PATCHES LIST END
|
||||||
|
110
use-cachedir-for-extension_modules-in-salt-call-bsc-.patch
Normal file
110
use-cachedir-for-extension_modules-in-salt-call-bsc-.patch
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
From 2fb453d04b8abe765a964174ae77d57398f2877a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Victor Zhestkov <vzhestkov@suse.com>
|
||||||
|
Date: Wed, 25 Sep 2024 14:06:19 +0300
|
||||||
|
Subject: [PATCH] Use --cachedir for extension_modules in salt-call
|
||||||
|
(bsc#1226141)
|
||||||
|
|
||||||
|
* Use --cachedir parameter for extension_modules with salt-call
|
||||||
|
|
||||||
|
* Add test to check extension_modules value alignment
|
||||||
|
---
|
||||||
|
salt/cli/call.py | 11 +++++++-
|
||||||
|
salt/config/__init__.py | 6 +++++
|
||||||
|
tests/pytests/unit/cli/test_salt_call.py | 32 ++++++++++++++++++++++++
|
||||||
|
3 files changed, 48 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100644 tests/pytests/unit/cli/test_salt_call.py
|
||||||
|
|
||||||
|
diff --git a/salt/cli/call.py b/salt/cli/call.py
|
||||||
|
index 932dc61681..be3ded77e6 100644
|
||||||
|
--- a/salt/cli/call.py
|
||||||
|
+++ b/salt/cli/call.py
|
||||||
|
@@ -3,7 +3,7 @@ import os
|
||||||
|
import salt.cli.caller
|
||||||
|
import salt.defaults.exitcodes
|
||||||
|
import salt.utils.parsers
|
||||||
|
-from salt.config import _expand_glob_path
|
||||||
|
+from salt.config import _expand_glob_path, prepend_root_dir
|
||||||
|
|
||||||
|
|
||||||
|
class SaltCall(salt.utils.parsers.SaltCallOptionParser):
|
||||||
|
@@ -37,6 +37,15 @@ class SaltCall(salt.utils.parsers.SaltCallOptionParser):
|
||||||
|
if self.options.master:
|
||||||
|
self.config["master"] = self.options.master
|
||||||
|
|
||||||
|
+ if self.options.cachedir and self.config.get(
|
||||||
|
+ "extension_modules"
|
||||||
|
+ ) == os.path.join(self.config.get("__cachedir"), "extmods"):
|
||||||
|
+ # Override `extension_modules`, but only in case if it was autogenerated
|
||||||
|
+ cache_dir = os.path.abspath(self.options.cachedir)
|
||||||
|
+ self.config["cachedir"] = cache_dir
|
||||||
|
+ self.config["extension_modules"] = os.path.join(cache_dir, "extmods")
|
||||||
|
+ prepend_root_dir(self.config, ["cachedir", "extension_modules"])
|
||||||
|
+
|
||||||
|
caller = salt.cli.caller.Caller.factory(self.config)
|
||||||
|
|
||||||
|
if self.options.doc:
|
||||||
|
diff --git a/salt/config/__init__.py b/salt/config/__init__.py
|
||||||
|
index 68f2b0f674..b3cd5d85ae 100644
|
||||||
|
--- a/salt/config/__init__.py
|
||||||
|
+++ b/salt/config/__init__.py
|
||||||
|
@@ -1,6 +1,7 @@
|
||||||
|
"""
|
||||||
|
All salt configuration loading and defaults should be in this module
|
||||||
|
"""
|
||||||
|
+
|
||||||
|
import codecs
|
||||||
|
import glob
|
||||||
|
import logging
|
||||||
|
@@ -3841,6 +3842,11 @@ def apply_minion_config(
|
||||||
|
_update_ssl_config(opts)
|
||||||
|
_update_discovery_config(opts)
|
||||||
|
|
||||||
|
+ # Store original `cachedir` value, before overriding,
|
||||||
|
+ # to make overriding more accurate.
|
||||||
|
+ if "__cachedir" not in opts:
|
||||||
|
+ opts["__cachedir"] = opts["cachedir"]
|
||||||
|
+
|
||||||
|
return opts
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/tests/pytests/unit/cli/test_salt_call.py b/tests/pytests/unit/cli/test_salt_call.py
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..078f2af70d
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/tests/pytests/unit/cli/test_salt_call.py
|
||||||
|
@@ -0,0 +1,32 @@
|
||||||
|
+import os
|
||||||
|
+
|
||||||
|
+from salt.cli.call import SaltCall
|
||||||
|
+from tests.support.mock import MagicMock, patch
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def test_passing_cachedir_to_extension_modules(temp_salt_minion):
|
||||||
|
+ """
|
||||||
|
+ Test passing `cachedir` CLI parameter to `extension_modules` opts
|
||||||
|
+ """
|
||||||
|
+ test_cache_dir = os.path.join(temp_salt_minion.config["root_dir"], "new_cache_tmp")
|
||||||
|
+ with patch(
|
||||||
|
+ "sys.argv",
|
||||||
|
+ [
|
||||||
|
+ "salt-call",
|
||||||
|
+ "--local",
|
||||||
|
+ "--config-dir",
|
||||||
|
+ temp_salt_minion.config["root_dir"],
|
||||||
|
+ "--cachedir",
|
||||||
|
+ test_cache_dir,
|
||||||
|
+ "test.true",
|
||||||
|
+ ],
|
||||||
|
+ ), patch("salt.utils.verify.verify_files", MagicMock()), patch(
|
||||||
|
+ "salt._logging.impl.setup_logfile_handler", MagicMock()
|
||||||
|
+ ):
|
||||||
|
+ salt_call = SaltCall()
|
||||||
|
+ with patch("salt.cli.caller.Caller.factory", MagicMock()) as caller_mock:
|
||||||
|
+ salt_call.run()
|
||||||
|
+ assert salt_call.config["cachedir"] == test_cache_dir
|
||||||
|
+ assert salt_call.config["extension_modules"] == os.path.join(
|
||||||
|
+ test_cache_dir, "extmods"
|
||||||
|
+ )
|
||||||
|
--
|
||||||
|
2.46.1
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user