Skip to content

Commit

Permalink
POC: workaround ps name problem
Browse files Browse the repository at this point in the history
  • Loading branch information
eg-ayoub committed Feb 20, 2024
1 parent 88acf64 commit c084c49
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion salt/_modules/metalk8s_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,24 @@ def get_listening_processes():
elif ip == "::":
ip = "0.0.0.0"

# workaround: as seen in https://github.com/shirou/gopsutil/pull/303/files
# ps sometimes will truncate process name
# here, we detect that and re-create process name from cmdline

_p = psutil.Process(sconn.pid)
_pname = _p.name()
if len(_pname) >= 15:
if _pname == "/opt/saltstack/":
if "/usr/bin/salt-api" in _p.cmdline():
_pname = "salt-api"
if "/usr/bin/salt-master" in _p.cmdline():
_pname = "salt-master"

all_listen_connections.setdefault(str(port), {}).update(
{
ip: {
"pid": sconn.pid,
"name": psutil.Process(sconn.pid).name(),
"name": _pname,
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ spec:
exec:
command:
- pgrep
- -f
- salt-master
periodSeconds: 10
initialDelaySeconds: 5
Expand Down

0 comments on commit c084c49

Please sign in to comment.