From 297637c78741c8348eb053ddd0b3bc12d068a9e2 Mon Sep 17 00:00:00 2001 From: kshithijiyer Date: Tue, 28 Apr 2020 12:58:07 +0530 Subject: [Libfix] Fix check_brick_pid_matches_glusterfsd_pid() to use pgrep Problem: On latest platforms pidof command is returning multiple pids as shown below: 27190 27078 26854 This is becasue it was returning glusterd,glusterfsd and glusterfs processes as well. The problem is that /usr/sbin/glusterd is a link to glusterfsd. 'pidof' has a new feature that pidof searches for the pattern in /proc/PID/cmdline, /proc/PID/stat and finally /proc/PID/exe. Hence pidof matches realpath of /proc//exe as /usr/sbin/glusterfsd and results in glusterd, glusterfs and glusterfsd pids being returned in output. Fix: Use pgrep instead of pidof to get glusterfsd pids. And change the split logic accordingly. Change-Id: I729e05c3f4cacf7bf826592da965a94a49bb6f33 Signed-off-by: kshithijiyer --- glustolibs-gluster/glustolibs/gluster/brickmux_ops.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'glustolibs-gluster/glustolibs') diff --git a/glustolibs-gluster/glustolibs/gluster/brickmux_ops.py b/glustolibs-gluster/glustolibs/gluster/brickmux_ops.py index 3defdba8a..b56434741 100755 --- a/glustolibs-gluster/glustolibs/gluster/brickmux_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/brickmux_ops.py @@ -119,7 +119,7 @@ def check_brick_pid_matches_glusterfsd_pid(mnode, volname): "of brick path %s", brick_node, brick_path) _rc = False - cmd = "pidof glusterfsd" + cmd = "pgrep -x glusterfsd" ret, pid, _ = g.run(brick_node, cmd) if ret != 0: g.log.error("Failed to run the command %s on " @@ -127,7 +127,7 @@ def check_brick_pid_matches_glusterfsd_pid(mnode, volname): _rc = False else: - glusterfsd_pid = pid.split() + glusterfsd_pid = pid.split('\n')[:-1] if brick_pid not in glusterfsd_pid: g.log.error("Brick pid %s doesn't match glusterfsd " -- cgit