Skip to content

Commit

Permalink
Handle zombie processes when getting pids
Browse files Browse the repository at this point in the history
  • Loading branch information
twangboy authored and dwoz committed Oct 29, 2024
1 parent 2d11041 commit 1168334
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/pytests/pkg/downgrade/test_salt_downgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,26 @@ def _get_running_named_salt_pid(process_name):

pids = []
for proc in psutil.process_iter():
cmdl_strg = " ".join(str(element) for element in proc.cmdline())
if process_name in cmdl_strg:
pids.append(proc.pid)
cmd_line = ""
try:
cmd_line = " ".join(str(element) for element in proc.cmdline())
except psutil.ZombieProcess:
# Even though it's a zombie process, it still has a cmdl_string and
# a pid, so we'll use it
pass
if process_name in cmd_line:
try:
pids.append(proc.pid)
except psutil.NoSuchProcess:
# Process is now closed
continue

return pids


def test_salt_downgrade_minion(salt_call_cli, install_salt):
"""
Test an downgrade of Salt Minion.
Test a downgrade of Salt Minion.
"""
is_restart_fixed = packaging.version.parse(
install_salt.prev_version
Expand Down

0 comments on commit 1168334

Please sign in to comment.