Fix watchdog_setup bug.
authorTatsuo Ishii <ishii@postgresql.org>
Fri, 22 Aug 2025 06:35:48 +0000 (15:35 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Fri, 22 Aug 2025 06:35:48 +0000 (15:35 +0900)
Fix bug in commit 534e04a0e.

- If no argument is specified, watchdog_setup complains a shell script error.
- When VIP is requested, delegate_ip, if_up_cmd and if_up_cmd are
  added to pgpool.conf multiple times.

Reviewed-by: Bo Peng <pengbo@sraoss.co.jp
Author: Tatsuo Ishii <ishii@postgresql.org>

src/test/watchdog_setup.in

index dfa362471486ad29c1cb7bf42bd21a30743e50ea..c64152451c27d83701ccaf0cdd38ae4a17389cbb 100644 (file)
@@ -199,15 +199,16 @@ EOF
                echo "wd_port$n = $wd_port" >> $conf
                echo "heartbeat_hostname$n = 'localhost'" >> $conf
                echo "heartbeat_port$n = $wd_heartbeat_port" >> $conf
-               if [ $VIP != "" ];then
-                   echo "delegate_ip = '$VIP'" >> $conf
-                   echo "if_up_cmd = '/usr/bin/echo \"if_up_cmd executed\"'" >> $conf
-                   echo "if_down_cmd = 'usr/bin/echo \"if_down_cmd executed\"'" >> $conf
-                   echo "arping_cmd = '/usr/bin/true'" >> $conf
-               fi
                n=`expr $n + 1`
     done
 
+    if [ "$VIP" != "" ];then
+       echo "delegate_ip = '$VIP'" >> $conf
+       echo "if_up_cmd = '/usr/bin/echo \"if_up_cmd executed\"'" >> $conf
+       echo "if_down_cmd = 'usr/bin/echo \"if_down_cmd executed\"'" >> $conf
+       echo "arping_cmd = '/usr/bin/true'" >> $conf
+    fi
+
        echo "$id" >> $node_id_file
 }