Fix Ceph processes PID management control
When checking if a daemon is running (function daemon_is_running) the 'grep' command was not parsing the output correctly, leading to a misbehavior. When the 'daemon_id' value is set to 'controller' it would wrongly match with 'controller-1' or 'controller-0' strings. Example of string to parse: /usr/bin/ceph-mon -i controller-1 --pid-file \ /var/run/ceph/mon.controller-1.pid -c /etc/ceph/ceph.conf \ --mon-data /var/lib/ceph/data/ceph-controller-1 --cluster ceph /usr/bin/ceph-mon -i controller --pid-file \ /var/run/ceph/mon.controller.pid -c /etc/ceph/ceph.conf \ --cluster ceph Adding a space at the end of the search expression fixed the problem. Additionally, the command to set the 'pid_found' variable was changed. The processes are listed using 'ps ax' and its output is parsed using only one 'awk' command. Test-Plan: PASS: Manually check the output of 'ps ax' and the awk parsing. PASS: Manually check the output of the 'cat /proc/$pid/cmdline' and the grep parsing string. PASS: On AIO-DX, swact the controllers 10 times, checking if the PID files on /var/run/ceph/ are created correctly for mon.controller and mon.controller-0 or mon.controller-1 PASS: Remove the pid file while the process is running and check its status. The file should be recreated with the correct pid number and the output should show the process is running. PASS: Stop the process and run the status command. The output should show the process is not running. Closes-bug: 2095438 Signed-off-by: Felipe Sanches Zanoni <Felipe.SanchesZanoni@windriver.com> Change-Id: Ic13e645ca47ee4353abd552610ab311d7c6a01a4
This commit is contained in:
parent
03a837d396
commit
d7d04b2271
@ -737,12 +737,12 @@ daemon_is_running() {
|
||||
daemon_id=$3
|
||||
pidfile=$4
|
||||
do_cmd "if [ ! -e $pidfile ] ; then
|
||||
pid_found=\$(ps aux | grep \"$daemon -i $daemon_id\" | grep -v grep | awk '{print \$2}')
|
||||
[ \"\$pid_found\" != \"\" ] || exit 1 # no pid, presumably not running
|
||||
pid_found=\$(ps ax | awk '/$daemon -i $daemon_id / { if (\$5 != \"awk\" && \$5 != \"bash\") print \$1 }')
|
||||
[ -z \"\$pid_found\" ] && exit 1 # no pid, presumably not running
|
||||
echo \$pid_found > $pidfile
|
||||
fi
|
||||
pid=\`cat $pidfile\`
|
||||
cat /proc/\$pid/cmdline | tr '\\0' ' ' | grep $daemon | grep -qwe -i.$daemon_id && exit 0 # running
|
||||
cat /proc/\$pid/cmdline | tr '\\0' ' ' | grep -q '$daemon -i $daemon_id ' && exit 0 # running
|
||||
exit 1 # pid is something else" "" "okfail"
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user