Skip to content

Commit

Permalink
Refector and use a function
Browse files Browse the repository at this point in the history
  • Loading branch information
inqueue committed Jun 28, 2024
1 parent 878fb2d commit d5a6508
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions esrally/utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,17 @@ def find_all_other_rally_processes() -> List[psutil.Process]:
return others


def redact_cmdline(cmdline: list) -> List[str]:
"""
Redact client options in p.cmdline as it contains sensitive information like passwords
"""

return ["=".join((value.split("=")[0], '"*****"')) if "--client-options" in value else value for value in cmdline]


def kill_all(predicate: Callable[[psutil.Process], bool]) -> None:
def kill(p: psutil.Process):
# Redact client options as it contains sensitive information like passwords
p_cmdline = p.cmdline()
for i, s in enumerate(p_cmdline):
if "--client-options" in s:
p_cmdline[i] = "=".join((s.split("=")[0], '"*****"'))
logging.getLogger(__name__).info("Killing lingering process with PID [%s] and command line [%s].", p.pid, p_cmdline)
logging.getLogger(__name__).info("Killing lingering process with PID [%s] and command line [%s].", p.pid, redact_cmdline(p.cmdline))
p.kill()
# wait until process has terminated, at most 3 seconds. Otherwise we might run into race conditions with actor system
# sockets that are still open.
Expand Down

0 comments on commit d5a6508

Please sign in to comment.