Skip to content

Commit

Permalink
Removing the duplicate process check based on truncated name and rely…
Browse files Browse the repository at this point in the history
…ing on cmdline check (opensearch-project#553)

Signed-off-by: Prabhakar Sithanandam <prabhakar.s87@gmail.com>
  • Loading branch information
backslasht authored and finnroblin committed Jul 19, 2024
1 parent 9258748 commit 36ae197
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions osbenchmark/utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,7 @@ def run_subprocess_with_logging(command_line, header=None, level=logging.INFO, s

def is_benchmark_process(p):
cmdline = p.cmdline()
# On Linux, /proc/PID/status truncates the command name to 15 characters which matches both opensearch-benchmark
# and opensearch-benchmarkd. Hence, checking command line to exclude opensearch-benchmarkd process.
return p.name() == "opensearch-benchmark" or \
(p.name() == "opensearch-benc" and
len(cmdline) > 1 and
os.path.basename(cmdline[1]) != "opensearch-benchmarkd") or \
(len(cmdline) > 1 and
os.path.basename(cmdline[0].lower()).startswith("python") and
os.path.basename(cmdline[1]) == "opensearch-benchmark")
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/process_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_kills_only_benchmark_processes(self, process_iter):
other_process = ProcessTests.Process(104, "init", ["/usr/sbin/init"])
benchmark_process_p = ProcessTests.Process(105, "python3", ["/usr/bin/python3", "~/.local/bin/opensearch-benchmark"])
# On Linux, the process name is truncated to 15 characters.
benchmark_process_l = ProcessTests.Process(106, "opensearch-benc", ["/usr/bin/python3", "~/.local/bin/osbenchmark"])
benchmark_process_l = ProcessTests.Process(106, "opensearch-benc", ["/usr/bin/python3", "~/.local/bin/opensearch-benchmark"])
benchmark_process_e = ProcessTests.Process(107, "opensearch-benchmark", ["/usr/bin/python3", "~/.local/bin/opensearch-benchmark"])
benchmark_process_mac = ProcessTests.Process(108, "Python", ["/Python.app/Contents/MacOS/Python",
"~/.local/bin/opensearch-benchmark"])
Expand Down

0 comments on commit 36ae197

Please sign in to comment.