Blame SOURCES/bz1850779-azure-lb-fix-redirect-issue.patch

e72037
From d22700fc5d5098c683b465ea0fede43803fd4d6b Mon Sep 17 00:00:00 2001
e72037
From: Reid wahl <nrwahl@protonmail.com>
e72037
Date: Tue, 7 Jul 2020 02:18:09 -0700
e72037
Subject: [PATCH] azure-lb: Don't redirect nc listener output to pidfile
e72037
e72037
The `lb_start()` function spawns an `nc` listener background process
e72037
and echoes the resulting pid to `$pidfile`. Due to a bug in the
e72037
redirection, all future data received by the `nc` process is also
e72037
appended to `$pidfile`.
e72037
e72037
If binary data is received later and appended to `$pidfile`, the
e72037
monitor operation fails when `grep` searches the now-binary file.
e72037
e72037
```
e72037
line 97: kill: Binary: arguments must be process or job IDs ]
e72037
line 97: kill: file: arguments must be process or job IDs ]
e72037
line 97: kill: /var/run/nc_PF2_02.pid: arguments must be process or job
e72037
    IDs ]
e72037
line 97: kill: matches: arguments must be process or job IDs ]
e72037
```
e72037
e72037
Then the start operation fails during recovery. `lb_start()` spawns a
e72037
new `nc` process, but the old process is still running and using the
e72037
configured port.
e72037
e72037
```
e72037
nc_PF2_02_start_0:777:stderr [ Ncat: bind to :::62502: Address
e72037
    already in use. QUITTING. ]
e72037
```
e72037
e72037
This patch fixes the issue by removing the `nc &` command from the
e72037
section whose output gets redirected to `$pidfile`. Now, only the `nc`
e72037
PID is echoed to `$pidfile`.
e72037
e72037
Resolves: RHBZ#1850778
e72037
Resolves: RHBZ#1850779
e72037
---
e72037
 heartbeat/azure-lb | 3 ++-
e72037
 1 file changed, 2 insertions(+), 1 deletion(-)
e72037
e72037
diff --git a/heartbeat/azure-lb b/heartbeat/azure-lb
e72037
index 05c134514..05755d778 100755
e72037
--- a/heartbeat/azure-lb
e72037
+++ b/heartbeat/azure-lb
e72037
@@ -113,7 +113,8 @@ lb_start() {
e72037
 	if ! lb_monitor; then
e72037
 		ocf_log debug "Starting $process: $cmd"
e72037
 		# Execute the command as created above
e72037
-		eval "$cmd & echo \$!" > $pidfile
e72037
+		$cmd &
e72037
+		echo $! > $pidfile
e72037
 		if lb_monitor; then
e72037
 			ocf_log debug "$process: $cmd started successfully, calling monitor"
e72037
 			lb_monitor