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

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