From eb7c2de4db27ea3f6a59c20c590a2e5352468237 Mon Sep 17 00:00:00 2001 From: Tyler Rockwood Date: Fri, 16 Jun 2023 08:39:31 -0500 Subject: [PATCH] ducktape: improve pid dectection v2 Exclude commands that run `redpanda --version` from pgrep Signed-off-by: Tyler Rockwood (cherry picked from commit 14d174ee8a995406305dda78883bfb06506dc980) --- tests/rptest/services/redpanda.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/rptest/services/redpanda.py b/tests/rptest/services/redpanda.py index d63ab2b8c0cc..93582b5404a1 100644 --- a/tests/rptest/services/redpanda.py +++ b/tests/rptest/services/redpanda.py @@ -1771,13 +1771,17 @@ def redpanda_pid(self, node): # we need to look for redpanda pid. pids() method returns pids of both # nodejs server and redpanda try: - cmd = "pgrep --exact redpanda" - - for p in node.account.ssh_capture(cmd, - allow_fail=True, - callback=int): - return p - + cmd = "pgrep --list-full --exact redpanda" + for line in node.account.ssh_capture(cmd, + allow_fail=True, + timeout_sec=10): + # Ignore SSH commands that lookup the version of redpanda + # by running `redpanda --version` like in `self.get_version(node)` + if "--version" in line: + continue + # The pid is listed first, that's all we need + return int(line.split()[0]) + return None except (RemoteCommandError, ValueError): return None