SHA256
1
0
forked from pool/salt

Accepting request 925143 from systemsmanagement:saltstack

- Fix issues with salt-ssh's extra-filerefs
- Added:
  * fix-issues-with-salt-ssh-s-extra-filerefs.patch

- Fix crash when calling manage.not_alive runners
- Added:
  * fix-crash-when-calling-manage.not_alive-runners.patch

- Do not consider skipped targets as failed for ansible.playbooks state (bsc#1190446)
- Added:
  * 3003.3-do-not-consider-skipped-targets-as-failed-for.patch

OBS-URL: https://build.opensuse.org/request/show/925143
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/salt?expand=0&rev=121
This commit is contained in:
Dominique Leuenberger 2021-10-16 20:47:01 +00:00 committed by Git OBS Bridge
commit cadec2e30c
6 changed files with 1706 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
0f00e37ce7f38b6d92b7a2b04cb2faa03098b0fc
43d1aa8a46def69d5b6097d235e7c7a97d4635cf

View File

@ -0,0 +1,81 @@
From 3ecb98a9bd7a8d35cff6d0a5f34b7fea96f89da7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
<psuarezhernandez@suse.com>
Date: Fri, 8 Oct 2021 12:47:53 +0100
Subject: [PATCH] Fix crash when calling manage.not_alive runners
Fix unit tests for netlink_tool_remote_on
Drop wrong test
---
salt/utils/network.py | 1 +
tests/unit/utils/test_network.py | 17 ++++-------------
2 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/salt/utils/network.py b/salt/utils/network.py
index 0dd20c5599..f0f5f1e8ce 100644
--- a/salt/utils/network.py
+++ b/salt/utils/network.py
@@ -1701,6 +1701,7 @@ def _netlink_tool_remote_on(port, which_end):
elif "ESTAB" not in line:
continue
chunks = line.split()
+ local_host, local_port = chunks[3].rsplit(":", 1)
remote_host, remote_port = chunks[4].rsplit(":", 1)
if which_end == "remote_port" and int(remote_port) != int(port):
diff --git a/tests/unit/utils/test_network.py b/tests/unit/utils/test_network.py
index 637d5e9811..3060aba0aa 100644
--- a/tests/unit/utils/test_network.py
+++ b/tests/unit/utils/test_network.py
@@ -110,18 +110,14 @@ USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
salt-master python2.781106 35 tcp4 127.0.0.1:61115 127.0.0.1:4506
"""
-NETLINK_SS = """
-State Recv-Q Send-Q Local Address:Port Peer Address:Port
-ESTAB 0 0 127.0.0.1:56726 127.0.0.1:4505
-ESTAB 0 0 ::ffff:1.2.3.4:5678 ::ffff:1.2.3.4:4505
-"""
-
LINUX_NETLINK_SS_OUTPUT = """\
State Recv-Q Send-Q Local Address:Port Peer Address:Port
TIME-WAIT 0 0 [::1]:8009 [::1]:40368
LISTEN 0 128 127.0.0.1:5903 0.0.0.0:*
ESTAB 0 0 [::ffff:127.0.0.1]:4506 [::ffff:127.0.0.1]:32315
ESTAB 0 0 192.168.122.1:4506 192.168.122.177:24545
+ESTAB 0 0 127.0.0.1:56726 127.0.0.1:4505
+ESTAB 0 0 ::ffff:1.2.3.4:5678 ::ffff:1.2.3.4:4505
"""
IPV4_SUBNETS = {
@@ -633,11 +629,11 @@ class NetworkTestCase(TestCase):
with patch(
"subprocess.check_output", return_value=LINUX_NETLINK_SS_OUTPUT
):
- remotes = network._netlink_tool_remote_on("4506", "local")
+ remotes = network._netlink_tool_remote_on("4506", "local_port")
self.assertEqual(remotes, {"192.168.122.177", "::ffff:127.0.0.1"})
def test_netlink_tool_remote_on_b(self):
- with patch("subprocess.check_output", return_value=NETLINK_SS):
+ with patch("subprocess.check_output", return_value=LINUX_NETLINK_SS_OUTPUT):
remotes = network._netlink_tool_remote_on("4505", "remote_port")
self.assertEqual(remotes, {"127.0.0.1", "::ffff:1.2.3.4"})
@@ -1274,11 +1270,6 @@ class NetworkTestCase(TestCase):
):
self.assertEqual(network.get_fqhostname(), host)
- def test_netlink_tool_remote_on(self):
- with patch("subprocess.check_output", return_value=NETLINK_SS):
- remotes = network._netlink_tool_remote_on("4505", "remote")
- self.assertEqual(remotes, {"127.0.0.1", "::ffff:1.2.3.4"})
-
def test_is_fqdn(self):
"""
Test is_fqdn function passes possible FQDN names.
--
2.33.0

View File

@ -0,0 +1,139 @@
From ef433d6f02af87d45363ae07fe438a1d7747df13 Mon Sep 17 00:00:00 2001
From: "Daniel A. Wozniak" <dwozniak@saltstack.com>
Date: Thu, 7 Oct 2021 17:22:37 -0700
Subject: [PATCH] Fix issues with salt-ssh's extra-filerefs
Verify salt-ssh can import from map files in states
Add changelog for 60003.fixed
---
changelog/60003.fixed | 1 +
salt/client/ssh/__init__.py | 1 +
tests/pytests/integration/ssh/test_state.py | 94 +++++++++++++++++++++
3 files changed, 96 insertions(+)
create mode 100644 changelog/60003.fixed
create mode 100644 tests/pytests/integration/ssh/test_state.py
diff --git a/changelog/60003.fixed b/changelog/60003.fixed
new file mode 100644
index 0000000000..6fafbf5108
--- /dev/null
+++ b/changelog/60003.fixed
@@ -0,0 +1 @@
+Validate we can import map files in states
diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py
index 409d6e740e..76c57996d9 100644
--- a/salt/client/ssh/__init__.py
+++ b/salt/client/ssh/__init__.py
@@ -1161,6 +1161,7 @@ class Single:
opts_pkg["_ssh_version"] = self.opts["_ssh_version"]
opts_pkg["thin_dir"] = self.opts["thin_dir"]
opts_pkg["master_tops"] = self.opts["master_tops"]
+ opts_pkg["extra_filerefs"] = self.opts.get("extra_filerefs", "")
opts_pkg["__master_opts__"] = self.context["master_opts"]
if "known_hosts_file" in self.opts:
opts_pkg["known_hosts_file"] = self.opts["known_hosts_file"]
diff --git a/tests/pytests/integration/ssh/test_state.py b/tests/pytests/integration/ssh/test_state.py
new file mode 100644
index 0000000000..58330a5dd8
--- /dev/null
+++ b/tests/pytests/integration/ssh/test_state.py
@@ -0,0 +1,94 @@
+import pytest
+
+pytestmark = [
+ pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
+]
+
+
+@pytest.fixture(scope="module")
+def state_tree(base_env_state_tree_root_dir):
+ top_file = """
+ base:
+ 'localhost':
+ - basic
+ '127.0.0.1':
+ - basic
+ """
+ map_file = """
+ {%- set abc = "def" %}
+ """
+ state_file = """
+ {%- from "map.jinja" import abc with context %}
+
+ Ok with {{ abc }}:
+ test.succeed_without_changes
+ """
+ top_tempfile = pytest.helpers.temp_file(
+ "top.sls", top_file, base_env_state_tree_root_dir
+ )
+ map_tempfile = pytest.helpers.temp_file(
+ "map.jinja", map_file, base_env_state_tree_root_dir
+ )
+ state_tempfile = pytest.helpers.temp_file(
+ "test.sls", state_file, base_env_state_tree_root_dir
+ )
+
+ with top_tempfile, map_tempfile, state_tempfile:
+ yield
+
+
+@pytest.mark.slow_test
+def test_state_with_import(salt_ssh_cli, state_tree):
+ """
+ verify salt-ssh can use imported map files in states
+ """
+ ret = salt_ssh_cli.run("state.sls", "test")
+ assert ret.exitcode == 0
+ assert ret.json
+
+
+@pytest.fixture
+def nested_state_tree(base_env_state_tree_root_dir, tmpdir):
+ top_file = """
+ base:
+ 'localhost':
+ - basic
+ '127.0.0.1':
+ - basic
+ """
+ state_file = """
+ /{}/file.txt:
+ file.managed:
+ - source: salt://foo/file.jinja
+ - template: jinja
+ """.format(
+ tmpdir
+ )
+ file_jinja = """
+ {% from 'foo/map.jinja' import comment %}{{ comment }}
+ """
+ map_file = """
+ {% set comment = "blah blah" %}
+ """
+ statedir = base_env_state_tree_root_dir / "foo"
+ top_tempfile = pytest.helpers.temp_file(
+ "top.sls", top_file, base_env_state_tree_root_dir
+ )
+ map_tempfile = pytest.helpers.temp_file("map.jinja", map_file, statedir)
+ file_tempfile = pytest.helpers.temp_file("file.jinja", file_jinja, statedir)
+ state_tempfile = pytest.helpers.temp_file("init.sls", state_file, statedir)
+
+ with top_tempfile, map_tempfile, state_tempfile, file_tempfile:
+ yield
+
+
+@pytest.mark.slow_test
+def test_state_with_import_from_dir(salt_ssh_cli, nested_state_tree):
+ """
+ verify salt-ssh can use imported map files in states
+ """
+ ret = salt_ssh_cli.run(
+ "--extra-filerefs=salt://foo/map.jinja", "state.apply", "foo"
+ )
+ assert ret.exitcode == 0
+ assert ret.json
--
2.33.0

View File

@ -1,3 +1,27 @@
-------------------------------------------------------------------
Fri Oct 8 15:48:09 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
- Fix issues with salt-ssh's extra-filerefs
- Added:
* fix-issues-with-salt-ssh-s-extra-filerefs.patch
-------------------------------------------------------------------
Fri Oct 8 15:26:04 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
- Fix crash when calling manage.not_alive runners
- Added:
* fix-crash-when-calling-manage.not_alive-runners.patch
-------------------------------------------------------------------
Wed Oct 6 08:32:54 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
- Do not consider skipped targets as failed for ansible.playbooks state (bsc#1190446)
- Added:
* 3003.3-do-not-consider-skipped-targets-as-failed-for.patch
-------------------------------------------------------------------
Thu Sep 30 10:49:56 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>

View File

@ -170,6 +170,7 @@ Patch29: fix-wrong-test_mod_del_repo_multiline_values-test-af.patch
# PATCH-FIX_OPENSUSE https://github.com/openSUSE/salt/commit/a18ac47b75550bd55f4ca91dc221ed408881984c
Patch30: make-setup.py-script-to-not-require-setuptools-9.1.patch
# PATCH-FIX_OPENSUSE https://github.com/openSUSE/salt/pull/228 (missing upstream PR)
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/61017
Patch31: adds-explicit-type-cast-for-port.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/57123
Patch32: prevent-logging-deadlock-on-salt-api-subprocesses-bs.patch
@ -286,6 +287,12 @@ Patch68: templates-move-the-globals-up-to-the-environment-jin.patch
Patch69: 3003.3-postgresql-json-support-in-pillar-423.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/60980
Patch70: do-not-break-master_tops-for-minion-with-version-low.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/60983
Patch71: 3003.3-do-not-consider-skipped-targets-as-failed-for.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/61017
Patch72: fix-crash-when-calling-manage.not_alive-runners.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/61014
Patch73: fix-issues-with-salt-ssh-s-extra-filerefs.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -771,6 +778,9 @@ cp %{S:6} .
%patch68 -p1
%patch69 -p1
%patch70 -p1
%patch71 -p1
%patch72 -p1
%patch73 -p1
%build
# Putting /usr/bin at the front of $PATH is needed for RHEL/RES 7. Without this