diff --git a/changelog/66143.fixed.md b/changelog/66143.fixed.md new file mode 100644 index 000000000000..58ecbd163c5b --- /dev/null +++ b/changelog/66143.fixed.md @@ -0,0 +1 @@ +Fix systemctl with "try-restart" instead of "retry-restart" within the RPM spec, properly restarting upgraded services diff --git a/pkg/rpm/salt.spec b/pkg/rpm/salt.spec index 2821cfd2f05f..540f2fb42fe0 100644 --- a/pkg/rpm/salt.spec +++ b/pkg/rpm/salt.spec @@ -475,7 +475,7 @@ ln -s -f /opt/saltstack/salt/salt-cloud %{_bindir}/salt-cloud # %%systemd_post salt-master.service if [ $1 -gt 1 ] ; then # Upgrade - systemctl retry-restart salt-master.service >/dev/null 2>&1 || : + systemctl try-restart salt-master.service >/dev/null 2>&1 || : else # Initial installation systemctl preset salt-master.service >/dev/null 2>&1 || : @@ -503,7 +503,7 @@ fi # %%systemd_post salt-syndic.service if [ $1 -gt 1 ] ; then # Upgrade - systemctl retry-restart salt-syndic.service >/dev/null 2>&1 || : + systemctl try-restart salt-syndic.service >/dev/null 2>&1 || : else # Initial installation systemctl preset salt-syndic.service >/dev/null 2>&1 || : @@ -514,7 +514,7 @@ ln -s -f /opt/saltstack/salt/salt-syndic %{_bindir}/salt-syndic # %%systemd_post salt-minion.service if [ $1 -gt 1 ] ; then # Upgrade - systemctl retry-restart salt-minion.service >/dev/null 2>&1 || : + systemctl try-restart salt-minion.service >/dev/null 2>&1 || : else # Initial installation systemctl preset salt-minion.service >/dev/null 2>&1 || : @@ -543,7 +543,7 @@ ln -s -f /opt/saltstack/salt/salt-ssh %{_bindir}/salt-ssh # %%systemd_post salt-api.service if [ $1 -gt 1 ] ; then # Upgrade - systemctl retry-restart salt-api.service >/dev/null 2>&1 || : + systemctl try-restart salt-api.service >/dev/null 2>&1 || : else # Initial installation systemctl preset salt-api.service >/dev/null 2>&1 || : diff --git a/tests/pytests/pkg/downgrade/test_salt_downgrade.py b/tests/pytests/pkg/downgrade/test_salt_downgrade.py index ec090d17ddaf..43fe1cc30ddb 100644 --- a/tests/pytests/pkg/downgrade/test_salt_downgrade.py +++ b/tests/pytests/pkg/downgrade/test_salt_downgrade.py @@ -36,17 +36,25 @@ def test_salt_downgrade(salt_call_cli, install_salt): assert "Authentication information could" in use_lib.stderr # Verify there is a running minion by getting its PID + salt_name = "salt" if platform.is_windows(): process_name = "salt-minion.exe" else: process_name = "salt-minion" - old_pid = None + + old_pid = [] + + # psutil process name only returning first part of the command '/opt/saltstack/' + # need to check all of command line for salt-minion + # ['/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-minion MultiMinionProcessManager MinionProcessManager'] + # and psutil is only returning the salt-minion once 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 + if salt_name in proc.name(): + cmdl_strg = " ".join(str(element) for element in proc.cmdline()) + if process_name in cmdl_strg: + old_pid.append(proc.pid) + + assert old_pid # Downgrade Salt to the previous version and test install_salt.install(downgrade=True) @@ -61,13 +69,14 @@ def test_salt_downgrade(salt_call_cli, install_salt): # Verify there is a new running minion by getting its PID and comparing it # with the PID from before the upgrade - new_pid = None + new_pid = [] 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 + if salt_name in proc.name(): + cmdl_strg = " ".join(str(element) for element in proc.cmdline()) + if process_name in cmdl_strg: + new_pid.append(proc.pid) + + assert new_pid assert new_pid != old_pid ret = install_salt.proc.run(bin_file, "--version") diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index 241a3c63d0f4..d376d581adb9 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -32,17 +32,25 @@ def test_salt_upgrade(salt_call_cli, install_salt): assert "Authentication information could" in use_lib.stderr # Verify there is a running minion by getting its PID + salt_name = "salt" if platform.is_windows(): process_name = "salt-minion.exe" else: process_name = "salt-minion" - old_pid = None + + old_pid = [] + + # psutil process name only returning first part of the command '/opt/saltstack/' + # need to check all of command line for salt-minion + # ['/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-minion MultiMinionProcessManager MinionProcessManager'] + # and psutil is only returning the salt-minion once 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 + if salt_name in proc.name(): + cmdl_strg = " ".join(str(element) for element in proc.cmdline()) + if process_name in cmdl_strg: + old_pid.append(proc.pid) + + assert old_pid # Upgrade Salt from previous version and test install_salt.install(upgrade=True) @@ -54,13 +62,14 @@ def test_salt_upgrade(salt_call_cli, install_salt): # Verify there is a new running minion by getting its PID and comparing it # with the PID from before the upgrade - new_pid = None + new_pid = [] 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 + if salt_name in proc.name(): + cmdl_strg = " ".join(str(element) for element in proc.cmdline()) + if process_name in cmdl_strg: + new_pid.append(proc.pid) + + assert new_pid assert new_pid != old_pid if install_salt.relenv: