From 68c6fd4fbad2ea72d3f2d2d54f332a7fa70c4869 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 14 Feb 2024 15:42:43 +0000 Subject: [PATCH 01/13] Increase timeouts on problematic tests --- tests/integration/modules/test_decorators.py | 1 + tests/integration/modules/test_saltcheck.py | 1 + tests/integration/ssh/test_state.py | 1 + tests/pytests/functional/modules/test_ansiblegate.py | 1 + tests/pytests/integration/cli/test_matcher.py | 1 + tests/pytests/integration/cli/test_salt_deltaproxy.py | 1 + 6 files changed, 6 insertions(+) diff --git a/tests/integration/modules/test_decorators.py b/tests/integration/modules/test_decorators.py index a3f83cd87c9..5a1ed3817a7 100644 --- a/tests/integration/modules/test_decorators.py +++ b/tests/integration/modules/test_decorators.py @@ -4,6 +4,7 @@ from tests.support.case import ModuleCase @pytest.mark.windows_whitelisted +@pytest.mark.timeout_unless_on_windows(120) class DecoratorTest(ModuleCase): @pytest.mark.slow_test def test_module(self): diff --git a/tests/integration/modules/test_saltcheck.py b/tests/integration/modules/test_saltcheck.py index 394d80bb8ab..914b046fdd7 100644 --- a/tests/integration/modules/test_saltcheck.py +++ b/tests/integration/modules/test_saltcheck.py @@ -7,6 +7,7 @@ import pytest from tests.support.case import ModuleCase +@pytest.mark.timeout_unless_on_windows(120) class SaltcheckModuleTest(ModuleCase): """ Test the saltcheck module diff --git a/tests/integration/ssh/test_state.py b/tests/integration/ssh/test_state.py index 48f634f309f..3951358b9e2 100644 --- a/tests/integration/ssh/test_state.py +++ b/tests/integration/ssh/test_state.py @@ -18,6 +18,7 @@ log = logging.getLogger(__name__) @pytest.mark.slow_test +@pytest.mark.timeout_unless_on_windows(120) class SSHStateTest(SSHCase): """ testing the state system with salt-ssh diff --git a/tests/pytests/functional/modules/test_ansiblegate.py b/tests/pytests/functional/modules/test_ansiblegate.py index 0c51b622709..9a895426a8c 100644 --- a/tests/pytests/functional/modules/test_ansiblegate.py +++ b/tests/pytests/functional/modules/test_ansiblegate.py @@ -10,6 +10,7 @@ pytestmark = [ reason="ansible is not installed", ), pytest.mark.slow_test, + pytest.mark.timeout_unless_on_windows(120), ] diff --git a/tests/pytests/integration/cli/test_matcher.py b/tests/pytests/integration/cli/test_matcher.py index 5d3ef4e3309..c1e8db062aa 100644 --- a/tests/pytests/integration/cli/test_matcher.py +++ b/tests/pytests/integration/cli/test_matcher.py @@ -7,6 +7,7 @@ import salt.defaults.exitcodes pytestmark = [ pytest.mark.core_test, pytest.mark.windows_whitelisted, + pytest.mark.timeout_unless_on_windows(120), ] diff --git a/tests/pytests/integration/cli/test_salt_deltaproxy.py b/tests/pytests/integration/cli/test_salt_deltaproxy.py index 5a6e847b78a..b1b65b3cacb 100644 --- a/tests/pytests/integration/cli/test_salt_deltaproxy.py +++ b/tests/pytests/integration/cli/test_salt_deltaproxy.py @@ -19,6 +19,7 @@ pytestmark = [ reason="Deltaproxy minions do not currently work on spawning platforms.", ), pytest.mark.core_test, + pytest.mark.timeout_unless_on_windows(320), ] From 6fa6c86a47d49f7bf8cdac3c70c1b2b8e515bb78 Mon Sep 17 00:00:00 2001 From: ScriptAutomate Date: Thu, 8 Feb 2024 10:48:59 -0600 Subject: [PATCH 02/13] Fix systemd scriptlet calls in RPMs --- changelog/65987.fixed.md | 1 + pkg/rpm/salt.spec | 43 +++++++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 changelog/65987.fixed.md diff --git a/changelog/65987.fixed.md b/changelog/65987.fixed.md new file mode 100644 index 00000000000..0a5fdff03d2 --- /dev/null +++ b/changelog/65987.fixed.md @@ -0,0 +1 @@ +Fix RPM package systemd scriptlets to make RPM packages more universal diff --git a/pkg/rpm/salt.spec b/pkg/rpm/salt.spec index 90fcfb0f37b..e98ee13d788 100644 --- a/pkg/rpm/salt.spec +++ b/pkg/rpm/salt.spec @@ -432,17 +432,25 @@ find /etc/salt /opt/saltstack/salt /var/log/salt /var/cache/salt /var/run/salt \ # assumes systemd for RHEL 7 & 8 & 9 +# foregoing %systemd_* scriptlets due to RHEL 7/8 vs. RHEL 9 incompatibilities +## - Using hardcoded scriptlet definitions from RHEL 7/8 that are forward-compatible %preun master # RHEL 9 is giving warning msg if syndic is not installed, supress it -%systemd_preun salt-syndic.service > /dev/null 2>&1 +# %systemd_preun salt-syndic.service > /dev/null 2>&1 +systemctl --no-reload disable salt-syndic.service > /dev/null 2>&1 || : +systemctl stop salt-syndic.service > /dev/null 2>&1 || : %preun minion -%systemd_preun salt-minion.service +# %systemd_preun salt-minion.service +systemctl --no-reload disable salt-minion.service > /dev/null 2>&1 || : +systemctl stop salt-minion.service > /dev/null 2>&1 || : %preun api -%systemd_preun salt-api.service +# %systemd_preun salt-api.service +systemctl --no-reload disable salt-api.service > /dev/null 2>&1 || : +systemctl stop salt-api.service > /dev/null 2>&1 || : %post @@ -456,7 +464,8 @@ ln -s -f /opt/saltstack/salt/salt-cloud %{_bindir}/salt-cloud %post master -%systemd_post salt-master.service +# %systemd_post salt-master.service +systemctl preset salt-master.service >/dev/null 2>&1 || : ln -s -f /opt/saltstack/salt/salt %{_bindir}/salt ln -s -f /opt/saltstack/salt/salt-cp %{_bindir}/salt-cp ln -s -f /opt/saltstack/salt/salt-key %{_bindir}/salt-key @@ -477,11 +486,13 @@ if [ $1 -lt 2 ]; then fi %post syndic -%systemd_post salt-syndic.service +# %systemd_post salt-syndic.service +systemctl preset salt-syndic.service >/dev/null 2>&1 || : ln -s -f /opt/saltstack/salt/salt-syndic %{_bindir}/salt-syndic %post minion -%systemd_post salt-minion.service +# %systemd_post salt-minion.service +systemctl preset salt-minion.service >/dev/null 2>&1 || : ln -s -f /opt/saltstack/salt/salt-minion %{_bindir}/salt-minion ln -s -f /opt/saltstack/salt/salt-call %{_bindir}/salt-call ln -s -f /opt/saltstack/salt/salt-proxy %{_bindir}/salt-proxy @@ -503,7 +514,8 @@ fi ln -s -f /opt/saltstack/salt/salt-ssh %{_bindir}/salt-ssh %post api -%systemd_post salt-api.service +# %systemd_post salt-api.service +systemctl preset salt-api.service >/dev/null 2>&1 || : ln -s -f /opt/saltstack/salt/salt-api %{_bindir}/salt-api @@ -544,7 +556,9 @@ if [ $1 -eq 0 ]; then fi %postun master -%systemd_postun_with_restart salt-master.service +# %systemd_postun_with_restart salt-master.service +systemctl daemon-reload >/dev/null 2>&1 || : +systemctl try-restart salt-master.service >/dev/null 2>&1 || : if [ $1 -eq 0 ]; then if [ $(cat /etc/os-release | grep VERSION_ID | cut -d '=' -f 2 | sed 's/\"//g' | cut -d '.' -f 1) = "8" ]; then if [ -z "$(rpm -qi salt-minion | grep Name | grep salt-minion)" ]; then @@ -560,10 +574,14 @@ if [ $1 -eq 0 ]; then fi %postun syndic -%systemd_postun_with_restart salt-syndic.service +# %systemd_postun_with_restart salt-syndic.service +systemctl daemon-reload >/dev/null 2>&1 || : +systemctl try-restart salt-syndic.service >/dev/null 2>&1 || : %postun minion -%systemd_postun_with_restart salt-minion.service +# %systemd_postun_with_restart salt-minion.service +systemctl daemon-reload >/dev/null 2>&1 || : +systemctl try-restart salt-minion.service >/dev/null 2>&1 || : if [ $1 -eq 0 ]; then if [ $(cat /etc/os-release | grep VERSION_ID | cut -d '=' -f 2 | sed 's/\"//g' | cut -d '.' -f 1) = "8" ]; then if [ -z "$(rpm -qi salt-master | grep Name | grep salt-master)" ]; then @@ -579,8 +597,9 @@ if [ $1 -eq 0 ]; then fi %postun api -%systemd_postun_with_restart salt-api.service - +# %systemd_postun_with_restart salt-api.service +systemctl daemon-reload >/dev/null 2>&1 || : +systemctl try-restart salt-api.service >/dev/null 2>&1 || : %changelog * Fri Jan 26 2024 Salt Project Packaging - 3006.6 From 0917a5abf78cc55b9db14765c2db47fadec0795a Mon Sep 17 00:00:00 2001 From: Shane Lee Date: Fri, 9 Feb 2024 11:06:09 -0700 Subject: [PATCH 03/13] Update pkg upgrade/downgrade tests to check pids --- .../pkg/downgrade/test_salt_downgrade.py | 25 +++++++++++++++++ .../pytests/pkg/upgrade/test_salt_upgrade.py | 27 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/tests/pytests/pkg/downgrade/test_salt_downgrade.py b/tests/pytests/pkg/downgrade/test_salt_downgrade.py index f6a8ef17a23..ec090d17dda 100644 --- a/tests/pytests/pkg/downgrade/test_salt_downgrade.py +++ b/tests/pytests/pkg/downgrade/test_salt_downgrade.py @@ -1,4 +1,5 @@ import packaging.version +import psutil import pytest from pytestskipmarkers.utils import platform @@ -34,6 +35,19 @@ def test_salt_downgrade(salt_call_cli, install_salt): use_lib = salt_call_cli.run("--local", "github.get_repo_info", repo) assert "Authentication information could" in use_lib.stderr + # Verify there is a running minion by getting its PID + if platform.is_windows(): + process_name = "salt-minion.exe" + else: + process_name = "salt-minion" + old_pid = None + for proc in psutil.process_iter(): + if process_name in proc.name(): + if psutil.Process(proc.ppid()).name() != process_name: + old_pid = proc.pid + break + assert old_pid is not None + # Downgrade Salt to the previous version and test install_salt.install(downgrade=True) bin_file = "salt" @@ -45,6 +59,17 @@ def test_salt_downgrade(salt_call_cli, install_salt): elif platform.is_darwin() and install_salt.classic: bin_file = install_salt.bin_dir / "salt-call" + # Verify there is a new running minion by getting its PID and comparing it + # with the PID from before the upgrade + new_pid = None + for proc in psutil.process_iter(): + if process_name in proc.name(): + if psutil.Process(proc.ppid()).name() != process_name: + new_pid = proc.pid + break + assert new_pid is not None + assert new_pid != old_pid + ret = install_salt.proc.run(bin_file, "--version") assert ret.returncode == 0 assert packaging.version.parse( diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index d844b5807da..241a3c63d0f 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -1,5 +1,7 @@ import packaging.version +import psutil import pytest +from pytestskipmarkers.utils import platform def test_salt_upgrade(salt_call_cli, install_salt): @@ -29,6 +31,19 @@ def test_salt_upgrade(salt_call_cli, install_salt): use_lib = salt_call_cli.run("--local", "github.get_repo_info", repo) assert "Authentication information could" in use_lib.stderr + # Verify there is a running minion by getting its PID + if platform.is_windows(): + process_name = "salt-minion.exe" + else: + process_name = "salt-minion" + old_pid = None + for proc in psutil.process_iter(): + if process_name in proc.name(): + if psutil.Process(proc.ppid()).name() != process_name: + old_pid = proc.pid + break + assert old_pid is not None + # Upgrade Salt from previous version and test install_salt.install(upgrade=True) ret = salt_call_cli.run("test.version") @@ -37,8 +52,20 @@ def test_salt_upgrade(salt_call_cli, install_salt): install_salt.artifact_version ) + # Verify there is a new running minion by getting its PID and comparing it + # with the PID from before the upgrade + new_pid = None + for proc in psutil.process_iter(): + if process_name in proc.name(): + if psutil.Process(proc.ppid()).name() != process_name: + new_pid = proc.pid + break + assert new_pid is not None + assert new_pid != old_pid + if install_salt.relenv: new_py_version = install_salt.package_python_version() if new_py_version == original_py_version: # test pip install after an upgrade use_lib = salt_call_cli.run("--local", "github.get_repo_info", repo) + assert "Authentication information could" in use_lib.stderr From 0021cb870df20a4e583053b1bb6326fff7b3ee58 Mon Sep 17 00:00:00 2001 From: Shane Lee Date: Mon, 12 Feb 2024 15:00:45 -0700 Subject: [PATCH 04/13] Fix the spec file for RPMs Looked up the actual code for the macros being replaced Made sure we're doing the proper if statements Cleaned up the tests a little --- pkg/rpm/salt.spec | 62 ++++++++++++++----- .../pkg/integration/test_enabled_disabled.py | 6 +- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/pkg/rpm/salt.spec b/pkg/rpm/salt.spec index e98ee13d788..4da0d4535ed 100644 --- a/pkg/rpm/salt.spec +++ b/pkg/rpm/salt.spec @@ -437,20 +437,28 @@ find /etc/salt /opt/saltstack/salt /var/log/salt /var/cache/salt /var/run/salt \ %preun master # RHEL 9 is giving warning msg if syndic is not installed, supress it # %systemd_preun salt-syndic.service > /dev/null 2>&1 -systemctl --no-reload disable salt-syndic.service > /dev/null 2>&1 || : -systemctl stop salt-syndic.service > /dev/null 2>&1 || : - +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + systemctl --no-reload disable salt-syndic.service > /dev/null 2>&1 || : + systemctl stop salt-syndic.service > /dev/null 2>&1 || : +fi %preun minion # %systemd_preun salt-minion.service -systemctl --no-reload disable salt-minion.service > /dev/null 2>&1 || : -systemctl stop salt-minion.service > /dev/null 2>&1 || : +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + systemctl --no-reload disable salt-minion.service > /dev/null 2>&1 || : + systemctl stop salt-minion.service > /dev/null 2>&1 || : +fi %preun api # %systemd_preun salt-api.service -systemctl --no-reload disable salt-api.service > /dev/null 2>&1 || : -systemctl stop salt-api.service > /dev/null 2>&1 || : +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + systemctl --no-reload disable salt-api.service > /dev/null 2>&1 || : + systemctl stop salt-api.service > /dev/null 2>&1 || : +fi %post @@ -465,7 +473,10 @@ ln -s -f /opt/saltstack/salt/salt-cloud %{_bindir}/salt-cloud %post master # %systemd_post salt-master.service -systemctl preset salt-master.service >/dev/null 2>&1 || : +if [ $1 -eq 1 ] ; then + # Initial installation + systemctl preset salt-master.service >/dev/null 2>&1 || : +fi ln -s -f /opt/saltstack/salt/salt %{_bindir}/salt ln -s -f /opt/saltstack/salt/salt-cp %{_bindir}/salt-cp ln -s -f /opt/saltstack/salt/salt-key %{_bindir}/salt-key @@ -487,12 +498,18 @@ fi %post syndic # %systemd_post salt-syndic.service -systemctl preset salt-syndic.service >/dev/null 2>&1 || : +if [ $1 -eq 1 ] ; then + # Initial installation + systemctl preset salt-syndic.service >/dev/null 2>&1 || : +fi ln -s -f /opt/saltstack/salt/salt-syndic %{_bindir}/salt-syndic %post minion # %systemd_post salt-minion.service -systemctl preset salt-minion.service >/dev/null 2>&1 || : +if [ $1 -eq 1 ] ; then + # Initial installation + systemctl preset salt-minion.service >/dev/null 2>&1 || : +fi ln -s -f /opt/saltstack/salt/salt-minion %{_bindir}/salt-minion ln -s -f /opt/saltstack/salt/salt-call %{_bindir}/salt-call ln -s -f /opt/saltstack/salt/salt-proxy %{_bindir}/salt-proxy @@ -515,7 +532,10 @@ ln -s -f /opt/saltstack/salt/salt-ssh %{_bindir}/salt-ssh %post api # %systemd_post salt-api.service -systemctl preset salt-api.service >/dev/null 2>&1 || : +if [ $1 -eq 1 ] ; then + # Initial installation + systemctl preset salt-api.service >/dev/null 2>&1 || : +fi ln -s -f /opt/saltstack/salt/salt-api %{_bindir}/salt-api @@ -558,7 +578,10 @@ fi %postun master # %systemd_postun_with_restart salt-master.service systemctl daemon-reload >/dev/null 2>&1 || : -systemctl try-restart salt-master.service >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + systemctl try-restart salt-master.service >/dev/null 2>&1 || : +fi if [ $1 -eq 0 ]; then if [ $(cat /etc/os-release | grep VERSION_ID | cut -d '=' -f 2 | sed 's/\"//g' | cut -d '.' -f 1) = "8" ]; then if [ -z "$(rpm -qi salt-minion | grep Name | grep salt-minion)" ]; then @@ -576,12 +599,18 @@ fi %postun syndic # %systemd_postun_with_restart salt-syndic.service systemctl daemon-reload >/dev/null 2>&1 || : -systemctl try-restart salt-syndic.service >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + systemctl try-restart salt-syndic.service >/dev/null 2>&1 || : +fi %postun minion # %systemd_postun_with_restart salt-minion.service systemctl daemon-reload >/dev/null 2>&1 || : -systemctl try-restart salt-minion.service >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + systemctl try-restart salt-minion.service >/dev/null 2>&1 || : +fi if [ $1 -eq 0 ]; then if [ $(cat /etc/os-release | grep VERSION_ID | cut -d '=' -f 2 | sed 's/\"//g' | cut -d '.' -f 1) = "8" ]; then if [ -z "$(rpm -qi salt-master | grep Name | grep salt-master)" ]; then @@ -599,7 +628,10 @@ fi %postun api # %systemd_postun_with_restart salt-api.service systemctl daemon-reload >/dev/null 2>&1 || : -systemctl try-restart salt-api.service >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + systemctl try-restart salt-api.service >/dev/null 2>&1 || : +fi %changelog * Fri Jan 26 2024 Salt Project Packaging - 3006.6 diff --git a/tests/pytests/pkg/integration/test_enabled_disabled.py b/tests/pytests/pkg/integration/test_enabled_disabled.py index c6f0d75db8f..f08c1e34a44 100644 --- a/tests/pytests/pkg/integration/test_enabled_disabled.py +++ b/tests/pytests/pkg/integration/test_enabled_disabled.py @@ -7,15 +7,14 @@ def test_services(install_salt, salt_cli, salt_minion): """ Check if Services are enabled/disabled """ + services_disabled = [] + services_enabled = [] if install_salt.distro_id in ("ubuntu", "debian"): services_enabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"] - services_disabled = [] elif install_salt.distro_id in ("centos", "redhat", "amzn", "fedora"): - services_enabled = [] services_disabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"] elif install_salt.distro_id == "photon": if float(install_salt.distro_version) < 5: - services_enabled = [] services_disabled = [ "salt-master", "salt-minion", @@ -24,7 +23,6 @@ def test_services(install_salt, salt_cli, salt_minion): ] else: services_enabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"] - services_disabled = [] elif platform.is_darwin(): services_enabled = ["salt-minion"] services_disabled = [] From 89570462687440418e925c29d0b602b244302190 Mon Sep 17 00:00:00 2001 From: Shane Lee Date: Tue, 13 Feb 2024 08:06:09 -0700 Subject: [PATCH 05/13] Make Photon 3 & 4 tests like Photon 5 --- tests/pytests/pkg/integration/test_enabled_disabled.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/pytests/pkg/integration/test_enabled_disabled.py b/tests/pytests/pkg/integration/test_enabled_disabled.py index f08c1e34a44..b2293492701 100644 --- a/tests/pytests/pkg/integration/test_enabled_disabled.py +++ b/tests/pytests/pkg/integration/test_enabled_disabled.py @@ -14,15 +14,7 @@ def test_services(install_salt, salt_cli, salt_minion): elif install_salt.distro_id in ("centos", "redhat", "amzn", "fedora"): services_disabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"] elif install_salt.distro_id == "photon": - if float(install_salt.distro_version) < 5: - services_disabled = [ - "salt-master", - "salt-minion", - "salt-syndic", - "salt-api", - ] - else: - services_enabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"] + services_enabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"] elif platform.is_darwin(): services_enabled = ["salt-minion"] services_disabled = [] From 62a58e3cca946641cad77a12ca08e7bfab642a1f Mon Sep 17 00:00:00 2001 From: Shane Lee Date: Wed, 14 Feb 2024 11:15:51 -0700 Subject: [PATCH 06/13] Handle upgrade scenario --- pkg/rpm/salt.spec | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/pkg/rpm/salt.spec b/pkg/rpm/salt.spec index 4da0d4535ed..4053921d366 100644 --- a/pkg/rpm/salt.spec +++ b/pkg/rpm/salt.spec @@ -436,7 +436,7 @@ find /etc/salt /opt/saltstack/salt /var/log/salt /var/cache/salt /var/run/salt \ ## - Using hardcoded scriptlet definitions from RHEL 7/8 that are forward-compatible %preun master # RHEL 9 is giving warning msg if syndic is not installed, supress it -# %systemd_preun salt-syndic.service > /dev/null 2>&1 +# %%systemd_preun salt-syndic.service > /dev/null 2>&1 if [ $1 -eq 0 ] ; then # Package removal, not upgrade systemctl --no-reload disable salt-syndic.service > /dev/null 2>&1 || : @@ -444,7 +444,7 @@ if [ $1 -eq 0 ] ; then fi %preun minion -# %systemd_preun salt-minion.service +# %%systemd_preun salt-minion.service if [ $1 -eq 0 ] ; then # Package removal, not upgrade systemctl --no-reload disable salt-minion.service > /dev/null 2>&1 || : @@ -453,7 +453,7 @@ fi %preun api -# %systemd_preun salt-api.service +# %%systemd_preun salt-api.service if [ $1 -eq 0 ] ; then # Package removal, not upgrade systemctl --no-reload disable salt-api.service > /dev/null 2>&1 || : @@ -472,8 +472,11 @@ ln -s -f /opt/saltstack/salt/salt-cloud %{_bindir}/salt-cloud %post master -# %systemd_post salt-master.service -if [ $1 -eq 1 ] ; then +# %%systemd_post salt-master.service +if [ $1 -gt 1 ] ; then + # Upgrade + systemctl retry-restart salt-master.service >/dev/null 2>&1 || : +else # Initial installation systemctl preset salt-master.service >/dev/null 2>&1 || : fi @@ -497,16 +500,22 @@ if [ $1 -lt 2 ]; then fi %post syndic -# %systemd_post salt-syndic.service -if [ $1 -eq 1 ] ; then +# %%systemd_post salt-syndic.service +if [ $1 -gt 1 ] ; then + # Upgrade + systemctl retry-restart salt-syndic.service >/dev/null 2>&1 || : +else # Initial installation systemctl preset salt-syndic.service >/dev/null 2>&1 || : fi ln -s -f /opt/saltstack/salt/salt-syndic %{_bindir}/salt-syndic %post minion -# %systemd_post salt-minion.service -if [ $1 -eq 1 ] ; then +# %%systemd_post salt-minion.service +if [ $1 -gt 1 ] ; then + # Upgrade + systemctl retry-restart salt-minion.service >/dev/null 2>&1 || : +else # Initial installation systemctl preset salt-minion.service >/dev/null 2>&1 || : fi @@ -531,8 +540,11 @@ fi ln -s -f /opt/saltstack/salt/salt-ssh %{_bindir}/salt-ssh %post api -# %systemd_post salt-api.service -if [ $1 -eq 1 ] ; then +# %%systemd_post salt-api.service +if [ $1 -gt 1 ] ; then + # Upgrade + systemctl retry-restart salt-api.service >/dev/null 2>&1 || : +else # Initial installation systemctl preset salt-api.service >/dev/null 2>&1 || : fi @@ -576,7 +588,7 @@ if [ $1 -eq 0 ]; then fi %postun master -# %systemd_postun_with_restart salt-master.service +# %%systemd_postun_with_restart salt-master.service systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall @@ -597,7 +609,7 @@ if [ $1 -eq 0 ]; then fi %postun syndic -# %systemd_postun_with_restart salt-syndic.service +# %%systemd_postun_with_restart salt-syndic.service systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall @@ -605,7 +617,7 @@ if [ $1 -ge 1 ] ; then fi %postun minion -# %systemd_postun_with_restart salt-minion.service +# %%systemd_postun_with_restart salt-minion.service systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall @@ -626,7 +638,7 @@ if [ $1 -eq 0 ]; then fi %postun api -# %systemd_postun_with_restart salt-api.service +# %%systemd_postun_with_restart salt-api.service systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall From 9a04397c11c976f28d3537b064084a47f0918c95 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 12 Feb 2024 18:58:28 -0600 Subject: [PATCH 07/13] [3006.x] Clarify that state.apply with no arguments runs a highstate --- salt/modules/state.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/modules/state.py b/salt/modules/state.py index 72baf47f488..ca86bcc62dc 100644 --- a/salt/modules/state.py +++ b/salt/modules/state.py @@ -637,7 +637,8 @@ def apply_(mods=None, **kwargs): .. rubric:: APPLYING ALL STATES CONFIGURED IN TOP.SLS (A.K.A. :ref:`HIGHSTATE `) - To apply all configured states, simply run ``state.apply``: + To apply all configured states, simply run ``state.apply`` with no SLS + targets, like so: .. code-block:: bash From 332533b1c958c24470bc4d9238216bcd431db901 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Wed, 14 Feb 2024 00:55:36 -0700 Subject: [PATCH 08/13] Fix default request channel timeout regression --- changelog/66061.fixed.md | 2 ++ salt/config/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog/66061.fixed.md diff --git a/changelog/66061.fixed.md b/changelog/66061.fixed.md new file mode 100644 index 00000000000..1735b25b2a4 --- /dev/null +++ b/changelog/66061.fixed.md @@ -0,0 +1,2 @@ +Fix request channel default timeout regression. In 3006.5 it was changed from +60 to 30 and is now set back to 60 by default. diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 688cc5ea455..95a4de9e09a 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -1057,7 +1057,7 @@ DEFAULT_MINION_OPTS = immutabletypes.freeze( "pillar_cache": False, "pillar_cache_ttl": 3600, "pillar_cache_backend": "disk", - "request_channel_timeout": 30, + "request_channel_timeout": 60, "request_channel_tries": 3, "gpg_cache": False, "gpg_cache_ttl": 86400, From 056a77cca8935e296493cf388d538d3937670b5f Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Wed, 14 Feb 2024 00:57:39 -0700 Subject: [PATCH 09/13] Add missing changelog for 65932 --- changelog/65932.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/65932.fixed.md diff --git a/changelog/65932.fixed.md b/changelog/65932.fixed.md new file mode 100644 index 00000000000..cafb2bb0022 --- /dev/null +++ b/changelog/65932.fixed.md @@ -0,0 +1 @@ +Ensure minion channels are closed on any master connection error. From c6274471cf209cbfb35359471b4c7c1f667085df Mon Sep 17 00:00:00 2001 From: Thomas Phipps Date: Tue, 6 Feb 2024 17:15:40 +0000 Subject: [PATCH 10/13] the fix for grabbing just our events and not sseapes --- salt/client/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/client/__init__.py b/salt/client/__init__.py index 307ce8a0ad4..ebfbea48e7a 100644 --- a/salt/client/__init__.py +++ b/salt/client/__init__.py @@ -1204,7 +1204,7 @@ class LocalClient: continue # Anything below this point is expected to be a job return event. - if not raw["tag"].startswith(f"salt/job/{jid}/ret"): + if not raw["tag"].startswith(f"salt/job/{jid}/ret/"): log.debug("Skipping non return event: %s", raw["tag"]) continue if "return" not in raw["data"]: From 2dd0f2966335b1815e8073dfb5a4310a6bafa4a5 Mon Sep 17 00:00:00 2001 From: Thomas Phipps Date: Tue, 6 Feb 2024 17:18:57 +0000 Subject: [PATCH 11/13] add changelog --- changelog/65727.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/65727.fixed.md diff --git a/changelog/65727.fixed.md b/changelog/65727.fixed.md new file mode 100644 index 00000000000..fe507ce4f8c --- /dev/null +++ b/changelog/65727.fixed.md @@ -0,0 +1 @@ +catch only ret/ events not all returning events. From da31638f0a83da36b4057cc99cbef1e3cbd91d9a Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Thu, 8 Feb 2024 14:17:40 -0700 Subject: [PATCH 12/13] Add test for return fix --- tests/pytests/unit/test_client.py | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/pytests/unit/test_client.py b/tests/pytests/unit/test_client.py index 48a21873697..fde31f459fb 100644 --- a/tests/pytests/unit/test_client.py +++ b/tests/pytests/unit/test_client.py @@ -247,3 +247,44 @@ def test_pub_win32(salt_master_factory): "test.ping", tgt_type="nodegroup", ) + + +def test_invalid_event_tag_65727(master_opts, caplog): + """ + LocalClient.get_iter_returns handles non return event tags. + """ + minions = () + jid = "0815" + raw_return = {"id": "fake-id", "jid": jid, "data": "", "return": "fake-return"} + expected_return = {"fake-id": {"ret": "fake-return"}} + + def returns_iter(): + # Invalid return + yield { + "tag": "salt/job/0815/return/", + "data": { + "return": "fpp", + "id": "fake-id", + }, + } + # Valid return + yield { + "tag": "salt/job/0815/ret/", + "data": { + "return": "fpp", + "id": "fake-id", + }, + } + + with client.LocalClient(mopts=master_opts) as local_client: + # Returning a truthy value, the real method returns a salt returner but it's not used. + local_client.returns_for_job = MagicMock(return_value=True) + # Mock iter returns, we'll return one invalid and one valid return event. + local_client.get_returns_no_block = MagicMock(return_value=returns_iter()) + with caplog.at_level(logging.DEBUG): + # Validate we don't choke on the bad return, the method returns a + # valid respons and the invalid event tag is getting logged to + # debug. + for ret in local_client.get_iter_returns(jid, {"fake-id"}): + assert ret == {"fake-id": {"ret": "fpp"}} + assert "Skipping non return event: salt/job/0815/return/" in caplog.text From b27ae54c12429d0476ca9c96da8a263c8bdc8db7 Mon Sep 17 00:00:00 2001 From: Thomas Phipps Date: Fri, 9 Feb 2024 20:23:26 +0000 Subject: [PATCH 13/13] fix tests/pytests/functional/cli/test_batch.py::test_batch_issue_56273 --- tests/pytests/functional/cli/test_batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytests/functional/cli/test_batch.py b/tests/pytests/functional/cli/test_batch.py index e721b729cfe..8c69b48cf4a 100644 --- a/tests/pytests/functional/cli/test_batch.py +++ b/tests/pytests/functional/cli/test_batch.py @@ -140,7 +140,7 @@ class MockSubscriber: }, use_bin_type=True, ) - tag = "salt/job/{}/ret".format(jid).encode() + tag = f"salt/job/{jid}/ret/{minion_id}".encode() return b"".join([tag, b"\n\n", dumped]) def connect(self, timeout=None):