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

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