From a614fed3b21e54ab361abc07cd71f1612923b2f8 Mon Sep 17 00:00:00 2001 From: bixiaoyan Date: Tue, 29 Oct 2024 15:42:59 +0800 Subject: [PATCH] IPaddr2: improve fail logic and check ip_status after adding IP findif.sh: remove "local proto" to use global proto from the agents --- ...fail-logic-and-check-ip_status-after.patch | 135 ++++++++++++++++++ ...-local-proto-to-use-global-proto-fro.patch | 25 ++++ resource-agents.spec | 8 +- 3 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 backport-IPaddr2-improve-fail-logic-and-check-ip_status-after.patch create mode 100644 backport-findif.sh-remove-local-proto-to-use-global-proto-fro.patch diff --git a/backport-IPaddr2-improve-fail-logic-and-check-ip_status-after.patch b/backport-IPaddr2-improve-fail-logic-and-check-ip_status-after.patch new file mode 100644 index 0000000..58b7099 --- /dev/null +++ b/backport-IPaddr2-improve-fail-logic-and-check-ip_status-after.patch @@ -0,0 +1,135 @@ +From 6fab544e702a7601714cd017aecc00193f23ae72 Mon Sep 17 00:00:00 2001 +From: Oyvind Albrigtsen +Date: Fri, 11 Oct 2024 13:13:10 +0200 +Subject: [PATCH 11/11] IPaddr2: improve fail logic and check ip_status after + adding IP + +* check that the label got applied +* return OCF_ERR_GENERIC to avoid false-positive when IP was manually added before starting the resource +* check ip_status after adding IP to fail without having to wait for the first monitor-action + +Co-authored-by: Evan J. Felix +--- + heartbeat/IPaddr2 | 35 ++++++++++++++++++++++++++--------- + 1 file changed, 26 insertions(+), 9 deletions(-) + +diff --git a/heartbeat/IPaddr2 b/heartbeat/IPaddr2 +index e325aa57..27cae2d1 100755 +--- a/heartbeat/IPaddr2 ++++ b/heartbeat/IPaddr2 +@@ -586,7 +586,7 @@ ip_init() { + exit $rc + fi + fi +- ++ + SENDARPPIDFILE="$SENDARPPIDDIR/send_arp-$OCF_RESKEY_ip" + + if [ -n "$IFLABEL" ]; then +@@ -985,6 +985,7 @@ run_send_ua() { + # ok = served (for CIP: + hash bucket) + # partial = served and no hash bucket (CIP only) + # partial2 = served and no CIP iptables rule ++# partial3 = served with no label + # no = nothing + # + ip_served() { +@@ -1002,6 +1003,11 @@ ip_served() { + + if [ -z "$IP_CIP" ]; then + for i in $cur_nic; do ++ # check address label ++ if [ -n "$IFLABEL" ] && [ -z "`$IP2UTIL -o -f $FAMILY addr show $nic label $IFLABEL`" ]; then ++ echo partial3 ++ return 0 ++ fi + # only mark as served when on the same interfaces as $NIC + [ "$i" = "$NIC" ] || continue + echo "ok" +@@ -1065,7 +1071,12 @@ ip_start() { + if [ "$ip_status" = "ok" ]; then + exit $OCF_SUCCESS + fi +- ++ ++ if [ "$ip_status" = "partial3" ]; then ++ ocf_exit_reason "IP $OCF_RESKEY_ip available, but label missing" ++ exit $OCF_ERR_GENERIC ++ fi ++ + if [ -n "$IP_CIP" ] && ([ $ip_status = "no" ] || [ $ip_status = "partial2" ]); then + $MODPROBE ip_conntrack + $IPADDR2_CIP_IPTABLES -I INPUT -d $OCF_RESKEY_ip -i $NIC -j CLUSTERIP \ +@@ -1083,7 +1094,7 @@ ip_start() { + if [ -n "$IP_CIP" ] && [ $ip_status = "partial" ]; then + echo "+$IP_INC_NO" >$IP_CIP_FILE + fi +- ++ + if [ "$ip_status" = "no" ]; then + if ocf_is_true ${OCF_RESKEY_lvs_support}; then + for i in `find_interface $OCF_RESKEY_ip 32`; do +@@ -1094,7 +1105,7 @@ ip_start() { + esac + done + fi +- ++ + add_interface "$OCF_RESKEY_ip" "$NETMASK" "${BRDCAST:-none}" "$NIC" "$IFLABEL" "$METRIC" + rc=$? + +@@ -1102,6 +1113,12 @@ ip_start() { + ocf_exit_reason "Failed to add $OCF_RESKEY_ip" + exit $rc + fi ++ ++ ip_status=`ip_served` ++ if [ "$ip_status" != "ok" ]; then ++ ocf_exit_reason "Failed to add $OCF_RESKEY_ip with error $ip_status" ++ exit $OCF_ERR_GENERIC ++ fi + fi + + case $NIC in +@@ -1134,7 +1151,7 @@ ip_stop() { + ocf_take_lock $CIP_lockfile + ocf_release_lock_on_exit $CIP_lockfile + fi +- ++ + if [ -f "$SENDARPPIDFILE" ] ; then + kill `cat "$SENDARPPIDFILE"` + if [ $? -ne 0 ]; then +@@ -1171,17 +1188,17 @@ ip_stop() { + i=`expr $i + 1` + done + else +- ip_del_if="no" ++ ip_del_if="no" + fi + fi +- ++ + if [ "$ip_del_if" = "yes" ]; then + delete_interface $OCF_RESKEY_ip $NIC $NETMASK + if [ $? -ne 0 ]; then + ocf_exit_reason "Unable to remove IP [${OCF_RESKEY_ip} from interface [ $NIC ]" + exit $OCF_ERR_GENERIC + fi +- ++ + if ocf_is_true ${OCF_RESKEY_lvs_support}; then + restore_loopback "$OCF_RESKEY_ip" + fi +@@ -1200,7 +1217,7 @@ ip_monitor() { + run_arp_sender refresh + return $OCF_SUCCESS + ;; +- partial|no|partial2) ++ no) + exit $OCF_NOT_RUNNING + ;; + *) +-- +2.25.1 + diff --git a/backport-findif.sh-remove-local-proto-to-use-global-proto-fro.patch b/backport-findif.sh-remove-local-proto-to-use-global-proto-fro.patch new file mode 100644 index 0000000..405b1ed --- /dev/null +++ b/backport-findif.sh-remove-local-proto-to-use-global-proto-fro.patch @@ -0,0 +1,25 @@ +From db2aa652a846513d124ac445e1d1e16f332adaa1 Mon Sep 17 00:00:00 2001 +From: Oyvind Albrigtsen +Date: Wed, 2 Oct 2024 09:40:55 +0200 +Subject: [PATCH 07/10] findif.sh: remove "local proto" to use global proto + from the agents + +--- + heartbeat/findif.sh | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/heartbeat/findif.sh b/heartbeat/findif.sh +index 7b817f75..2ae91e95 100644 +--- a/heartbeat/findif.sh ++++ b/heartbeat/findif.sh +@@ -196,7 +196,6 @@ findif() + { + local match="$OCF_RESKEY_ip" + local family +- local proto + local scope + local nic="$OCF_RESKEY_nic" + local netmask="$OCF_RESKEY_cidr_netmask" +-- +2.25.1 + diff --git a/resource-agents.spec b/resource-agents.spec index 3d0bc69..0ec932f 100644 --- a/resource-agents.spec +++ b/resource-agents.spec @@ -1,7 +1,7 @@ Name: resource-agents Summary: Open Source HA Reusable Cluster Resource Scripts Version: 4.15.1 -Release: 8 +Release: 9 License: GPLv2+ and LGPLv2+ URL: https://github.com/ClusterLabs/resource-agents Source0: https://github.com/ClusterLabs/resource-agents/archive/v%{version}.tar.gz @@ -20,6 +20,8 @@ Patch10: backport-IPaddr2-add-proto-parameter-to-be-able-to-match-a- Patch11: backport-podman-Improve-handling-of-stopping-container-remova.patch Patch12: backport-apache-http-mon_sh-change-curl-opts-to-match-wget.patch Patch13: backport-apache-http-mon_sh-doc-curl-as-preferred-client.patch +Patch14: backport-IPaddr2-improve-fail-logic-and-check-ip_status-after.patch +Patch15: backport-findif.sh-remove-local-proto-to-use-global-proto-fro.patch Obsoletes: heartbeat-resources <= %{version} Provides: heartbeat-resources = %{version} @@ -118,6 +120,10 @@ export CFLAGS="$(echo '%{optflags}')" %{_mandir}/man8/{ocf-tester.8*,ldirectord.8*} %changelog +* Tue Oct 29 2024 bixiaoyan - 4.15.1-9 +- IPaddr2: improve fail logic and check ip_status after adding IP +- findif.sh: remove "local proto" to use global proto from the agents + * Fri Oct 25 2024 liupei - 4.15.1-8 - apache/http-mon.sh: change curl opts to match wget - apache/http-mon.sh: doc curl as preferred client -- Gitee