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

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