mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Fix RedHat family systemd restart on upgrade, and updated tests
This commit is contained in:
parent
87d3344a7a
commit
53fce6957d
4 changed files with 47 additions and 28 deletions
1
changelog/66143.fixed.md
Normal file
1
changelog/66143.fixed.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix systemctl with "try-restart" instead of "retry-restart" within the RPM spec, properly restarting upgraded services
|
|
@ -475,7 +475,7 @@ ln -s -f /opt/saltstack/salt/salt-cloud %{_bindir}/salt-cloud
|
||||||
# %%systemd_post salt-master.service
|
# %%systemd_post salt-master.service
|
||||||
if [ $1 -gt 1 ] ; then
|
if [ $1 -gt 1 ] ; then
|
||||||
# Upgrade
|
# Upgrade
|
||||||
systemctl retry-restart salt-master.service >/dev/null 2>&1 || :
|
systemctl try-restart salt-master.service >/dev/null 2>&1 || :
|
||||||
else
|
else
|
||||||
# Initial installation
|
# Initial installation
|
||||||
systemctl preset salt-master.service >/dev/null 2>&1 || :
|
systemctl preset salt-master.service >/dev/null 2>&1 || :
|
||||||
|
@ -503,7 +503,7 @@ fi
|
||||||
# %%systemd_post salt-syndic.service
|
# %%systemd_post salt-syndic.service
|
||||||
if [ $1 -gt 1 ] ; then
|
if [ $1 -gt 1 ] ; then
|
||||||
# Upgrade
|
# Upgrade
|
||||||
systemctl retry-restart salt-syndic.service >/dev/null 2>&1 || :
|
systemctl try-restart salt-syndic.service >/dev/null 2>&1 || :
|
||||||
else
|
else
|
||||||
# Initial installation
|
# Initial installation
|
||||||
systemctl preset salt-syndic.service >/dev/null 2>&1 || :
|
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
|
# %%systemd_post salt-minion.service
|
||||||
if [ $1 -gt 1 ] ; then
|
if [ $1 -gt 1 ] ; then
|
||||||
# Upgrade
|
# Upgrade
|
||||||
systemctl retry-restart salt-minion.service >/dev/null 2>&1 || :
|
systemctl try-restart salt-minion.service >/dev/null 2>&1 || :
|
||||||
else
|
else
|
||||||
# Initial installation
|
# Initial installation
|
||||||
systemctl preset salt-minion.service >/dev/null 2>&1 || :
|
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
|
# %%systemd_post salt-api.service
|
||||||
if [ $1 -gt 1 ] ; then
|
if [ $1 -gt 1 ] ; then
|
||||||
# Upgrade
|
# Upgrade
|
||||||
systemctl retry-restart salt-api.service >/dev/null 2>&1 || :
|
systemctl try-restart salt-api.service >/dev/null 2>&1 || :
|
||||||
else
|
else
|
||||||
# Initial installation
|
# Initial installation
|
||||||
systemctl preset salt-api.service >/dev/null 2>&1 || :
|
systemctl preset salt-api.service >/dev/null 2>&1 || :
|
||||||
|
|
|
@ -36,17 +36,25 @@ def test_salt_downgrade(salt_call_cli, install_salt):
|
||||||
assert "Authentication information could" in use_lib.stderr
|
assert "Authentication information could" in use_lib.stderr
|
||||||
|
|
||||||
# Verify there is a running minion by getting its PID
|
# Verify there is a running minion by getting its PID
|
||||||
|
salt_name = "salt"
|
||||||
if platform.is_windows():
|
if platform.is_windows():
|
||||||
process_name = "salt-minion.exe"
|
process_name = "salt-minion.exe"
|
||||||
else:
|
else:
|
||||||
process_name = "salt-minion"
|
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():
|
for proc in psutil.process_iter():
|
||||||
if process_name in proc.name():
|
if salt_name in proc.name():
|
||||||
if psutil.Process(proc.ppid()).name() != process_name:
|
cmdl_strg = " ".join(str(element) for element in proc.cmdline())
|
||||||
old_pid = proc.pid
|
if process_name in cmdl_strg:
|
||||||
break
|
old_pid.append(proc.pid)
|
||||||
assert old_pid is not None
|
|
||||||
|
assert old_pid
|
||||||
|
|
||||||
# Downgrade Salt to the previous version and test
|
# Downgrade Salt to the previous version and test
|
||||||
install_salt.install(downgrade=True)
|
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
|
# Verify there is a new running minion by getting its PID and comparing it
|
||||||
# with the PID from before the upgrade
|
# with the PID from before the upgrade
|
||||||
new_pid = None
|
new_pid = []
|
||||||
for proc in psutil.process_iter():
|
for proc in psutil.process_iter():
|
||||||
if process_name in proc.name():
|
if salt_name in proc.name():
|
||||||
if psutil.Process(proc.ppid()).name() != process_name:
|
cmdl_strg = " ".join(str(element) for element in proc.cmdline())
|
||||||
new_pid = proc.pid
|
if process_name in cmdl_strg:
|
||||||
break
|
new_pid.append(proc.pid)
|
||||||
assert new_pid is not None
|
|
||||||
|
assert new_pid
|
||||||
assert new_pid != old_pid
|
assert new_pid != old_pid
|
||||||
|
|
||||||
ret = install_salt.proc.run(bin_file, "--version")
|
ret = install_salt.proc.run(bin_file, "--version")
|
||||||
|
|
|
@ -32,17 +32,25 @@ def test_salt_upgrade(salt_call_cli, install_salt):
|
||||||
assert "Authentication information could" in use_lib.stderr
|
assert "Authentication information could" in use_lib.stderr
|
||||||
|
|
||||||
# Verify there is a running minion by getting its PID
|
# Verify there is a running minion by getting its PID
|
||||||
|
salt_name = "salt"
|
||||||
if platform.is_windows():
|
if platform.is_windows():
|
||||||
process_name = "salt-minion.exe"
|
process_name = "salt-minion.exe"
|
||||||
else:
|
else:
|
||||||
process_name = "salt-minion"
|
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():
|
for proc in psutil.process_iter():
|
||||||
if process_name in proc.name():
|
if salt_name in proc.name():
|
||||||
if psutil.Process(proc.ppid()).name() != process_name:
|
cmdl_strg = " ".join(str(element) for element in proc.cmdline())
|
||||||
old_pid = proc.pid
|
if process_name in cmdl_strg:
|
||||||
break
|
old_pid.append(proc.pid)
|
||||||
assert old_pid is not None
|
|
||||||
|
assert old_pid
|
||||||
|
|
||||||
# Upgrade Salt from previous version and test
|
# Upgrade Salt from previous version and test
|
||||||
install_salt.install(upgrade=True)
|
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
|
# Verify there is a new running minion by getting its PID and comparing it
|
||||||
# with the PID from before the upgrade
|
# with the PID from before the upgrade
|
||||||
new_pid = None
|
new_pid = []
|
||||||
for proc in psutil.process_iter():
|
for proc in psutil.process_iter():
|
||||||
if process_name in proc.name():
|
if salt_name in proc.name():
|
||||||
if psutil.Process(proc.ppid()).name() != process_name:
|
cmdl_strg = " ".join(str(element) for element in proc.cmdline())
|
||||||
new_pid = proc.pid
|
if process_name in cmdl_strg:
|
||||||
break
|
new_pid.append(proc.pid)
|
||||||
assert new_pid is not None
|
|
||||||
|
assert new_pid
|
||||||
assert new_pid != old_pid
|
assert new_pid != old_pid
|
||||||
|
|
||||||
if install_salt.relenv:
|
if install_salt.relenv:
|
||||||
|
|
Loading…
Add table
Reference in a new issue