Blame SOURCES/bz1635785-redis-pidof-basename.patch

05afe3
From 2462caf264c487810805c40a546a4dc3f953c340 Mon Sep 17 00:00:00 2001
05afe3
From: Michele Baldessari <michele@acksyn.org>
05afe3
Date: Wed, 3 Oct 2018 18:07:31 +0200
05afe3
Subject: [PATCH] Do not use the absolute path in redis' pidof calls
05afe3
05afe3
The reason for this is that newer kernels (we saw this on a 4.18 kernel)
05afe3
can limit access to /proc/<pid>/{cwd,exe,root} and so pidof will fail to
05afe3
identify the process when using the full path names.
05afe3
This access limitation happens even with the root user:
05afe3
()[root@ra1 /]$ ls -l /proc/32/ |grep redis-server
05afe3
ls: cannot read symbolic link '/proc/32/cwd': Permission denied
05afe3
ls: cannot read symbolic link '/proc/32/root': Permission denied
05afe3
ls: cannot read symbolic link '/proc/32/exe': Permission denied
05afe3
05afe3
For this reason the 'pidof /usr/bin/redis-server' calls will fail
05afe3
when running inside containers that have this kernel protection
05afe3
mechanism.
05afe3
05afe3
We tested this change and successfuly obtained a running redis cluster:
05afe3
 podman container set: redis-bundle [192.168.222.1:5000/redis:latest]
05afe3
   Replica[0]
05afe3
      redis-bundle-podman-0     (ocf::heartbeat:podman):        Started ra1
05afe3
      redis-bundle-0    (ocf::pacemaker:remote):        Started ra1
05afe3
      redis     (ocf::heartbeat:redis): Master redis-bundle-0
05afe3
   Replica[1]
05afe3
      redis-bundle-podman-1     (ocf::heartbeat:podman):        Started ra2
05afe3
      redis-bundle-1    (ocf::pacemaker:remote):        Started ra2
05afe3
      redis     (ocf::heartbeat:redis): Slave redis-bundle-1
05afe3
   Replica[2]
05afe3
      redis-bundle-podman-2     (ocf::heartbeat:podman):        Started ra3
05afe3
      redis-bundle-2    (ocf::pacemaker:remote):        Started ra3
05afe3
      redis     (ocf::heartbeat:redis): Slave redis-bundle-2
05afe3
05afe3
Signed-off-By: Damien Ciabrini <dciabrin@redhat.com>
05afe3
Signed-off-by: Michele Baldessari <michele@acksyn.org>
05afe3
---
05afe3
 heartbeat/redis.in | 4 ++--
05afe3
 1 file changed, 2 insertions(+), 2 deletions(-)
05afe3
05afe3
diff --git a/heartbeat/redis.in b/heartbeat/redis.in
05afe3
index ddc62d8a7..1dff067e9 100644
05afe3
--- a/heartbeat/redis.in
05afe3
+++ b/heartbeat/redis.in
05afe3
@@ -316,7 +316,7 @@ simple_status() {
05afe3
 	fi
05afe3
 
05afe3
 	pid="$(<"$REDIS_PIDFILE")"
05afe3
-	pidof "$REDIS_SERVER" | grep -q "\<$pid\>" || return $OCF_NOT_RUNNING
05afe3
+	pidof $(basename "$REDIS_SERVER") | grep -q "\<$pid\>" || return $OCF_NOT_RUNNING
05afe3
 
05afe3
 	ocf_log debug "monitor: redis-server running under pid $pid"
05afe3
 
05afe3
@@ -465,7 +465,7 @@ redis_start() {
05afe3
 			break
05afe3
 		elif (( info[loading] == 1 )); then
05afe3
 			sleep "${info[loading_eta_seconds]}"
05afe3
-		elif pidof "$REDIS_SERVER" >/dev/null; then
05afe3
+		elif pidof $(basename "$REDIS_SERVER") >/dev/null; then
05afe3
 			# unknown error, but the process still exists.
05afe3
 			# This check is mainly because redis daemonizes before it starts listening, causing `redis-cli` to fail
05afe3
 			#   See https://github.com/antirez/redis/issues/2368