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

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