From 23db4dc66f5f7bd36fd436cb822637cc095abb61 Mon Sep 17 00:00:00 2001 From: liupei Date: Wed, 24 Jul 2024 11:14:25 +0800 Subject: [PATCH] crm-fence-peer.9.sh: fix parsing in_ccm crmd fields of node_state with Pacemaker 2.1.7 and use join of node_state to judge whether node is banned --- ....sh-fix-parsing-in_ccm-crmd-fields-o.patch | 101 ++++++++++++++++++ ....sh-use-join-of-node_state-to-judge-.patch | 44 ++++++++ drbd.spec | 10 +- 3 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 backport-crm-fence-peer.9.sh-fix-parsing-in_ccm-crmd-fields-o.patch create mode 100644 backport-crm-fence-peer.9.sh-use-join-of-node_state-to-judge-.patch diff --git a/backport-crm-fence-peer.9.sh-fix-parsing-in_ccm-crmd-fields-o.patch b/backport-crm-fence-peer.9.sh-fix-parsing-in_ccm-crmd-fields-o.patch new file mode 100644 index 0000000..6d9795a --- /dev/null +++ b/backport-crm-fence-peer.9.sh-fix-parsing-in_ccm-crmd-fields-o.patch @@ -0,0 +1,101 @@ +From 7506d0ee973d93a90ae5e41e62c4693b5c4e954d Mon Sep 17 00:00:00 2001 +From: Su Yue +Date: Sun, 3 Mar 2024 17:12:58 +0800 +Subject: [PATCH 030/100] crm-fence-peer.9.sh: fix parsing in_ccm crmd fields + of node_state with Pacemaker 2.1.7 + +If pacemaker version < 2.1.7, in_ccm of node_state is "true" or "false" +and crmd is "online" or "offline". + +pacemaker 2.1.7 changed the two fields into timestamps. +For in_ccm, the value is timestamp since when node has been a cluster +member("true"). A value 0 of means the node is not a cluster member("false"). +For crmd, the value is timestamp since when peer has been online in +CPG("online"). A value 0 means the peer is offline in CPG("offline"). + +The original code doesn't handle these fields in timestamp format. +Since there are many comprare of strings in context, converting in_ccm and crmd +from timestamps/0 to old strings is simpler and clearer. + +Link: https://github.com/ClusterLabs/pacemaker/blob/Pacemaker-2.1.7/lib/pengine/unpack.c#L1581 +Signed-off-by: Su Yue +--- + scripts/crm-fence-peer.9.sh | 25 +++++++++++++++++++++++++ + scripts/crm-fence-peer.sh | 25 +++++++++++++++++++++++++ + 2 files changed, 50 insertions(+) + +diff --git a/scripts/crm-fence-peer.9.sh b/scripts/crm-fence-peer.9.sh +index 44da6516..a3353a73 100755 +--- a/scripts/crm-fence-peer.9.sh ++++ b/scripts/crm-fence-peer.9.sh +@@ -888,6 +888,31 @@ guess_if_pacemaker_will_fence() + esac + done + ++ # Copied from pacemaker-2.1.7:lib/pengine/unpack.c: ++ # Since crm_feature_set 3.18.0 (pacemaker-2.1.7): ++ # ++ # - in_ccm ::= |0 ++ # Since when node has been a cluster member. A value 0 of means the ++ # node is not a cluster member. ++ # - crmd ::= |0 ++ # Since when peer has been online in CPG. A value 0 means the peer ++ # is offline in CPG. ++ if [[ $in_ccm =~ ^[0-9]+$ ]]; then ++ if [[ $in_ccm = "0" ]]; then ++ in_ccm="false" ++ else ++ in_ccm="true" ++ fi ++ fi ++ ++ if [[ $crmd =~ ^[0-9]+$ ]]; then ++ if [[ $crmd = "0" ]]; then ++ crmd="offline" ++ else ++ crmd="online" ++ fi ++ fi ++ + # if it is not enabled, no point in waiting for it. + if ! $stonith_enabled ; then + # "normalize" the rest of the logic +diff --git a/scripts/crm-fence-peer.sh b/scripts/crm-fence-peer.sh +index 841ea797..61e3145f 100755 +--- a/scripts/crm-fence-peer.sh ++++ b/scripts/crm-fence-peer.sh +@@ -561,6 +561,31 @@ guess_if_pacemaker_will_fence() + esac + done + ++ # Copied from pacemaker-2.1.7:lib/pengine/unpack.c: ++ # Since crm_feature_set 3.18.0 (pacemaker-2.1.7): ++ # ++ # - in_ccm ::= |0 ++ # Since when node has been a cluster member. A value 0 of means the ++ # node is not a cluster member. ++ # - crmd ::= |0 ++ # Since when peer has been online in CPG. A value 0 means the peer ++ # is offline in CPG. ++ if [[ $in_ccm =~ ^[0-9]+$ ]]; then ++ if [[ $in_ccm = "0" ]]; then ++ in_ccm="false" ++ else ++ in_ccm="true" ++ fi ++ fi ++ ++ if [[ $crmd =~ ^[0-9]+$ ]]; then ++ if [[ $crmd = "0" ]]; then ++ crmd="offline" ++ else ++ crmd="online" ++ fi ++ fi ++ + # if it is not enabled, no point in waiting for it. + if ! $stonith_enabled ; then + # "normalize" the rest of the logic +-- +2.33.1.windows.1 + diff --git a/backport-crm-fence-peer.9.sh-use-join-of-node_state-to-judge-.patch b/backport-crm-fence-peer.9.sh-use-join-of-node_state-to-judge-.patch new file mode 100644 index 0000000..64f6d13 --- /dev/null +++ b/backport-crm-fence-peer.9.sh-use-join-of-node_state-to-judge-.patch @@ -0,0 +1,44 @@ +From 4ef967dd140cfd636574557133064ce2330540f8 Mon Sep 17 00:00:00 2001 +From: Su Yue +Date: Sun, 3 Mar 2024 17:12:59 +0800 +Subject: [PATCH 031/100] crm-fence-peer.9.sh: use join of node_state to judge + whether node is banned + +crmd in node_state can't be "banned". join should be used instead +of crmd. + +Signed-off-by: Su Yue +--- + scripts/crm-fence-peer.9.sh | 2 +- + scripts/crm-fence-peer.sh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/scripts/crm-fence-peer.9.sh b/scripts/crm-fence-peer.9.sh +index a3353a73..b326a165 100755 +--- a/scripts/crm-fence-peer.9.sh ++++ b/scripts/crm-fence-peer.9.sh +@@ -934,7 +934,7 @@ guess_if_pacemaker_will_fence() + + # for further inspiration, see pacemaker:lib/pengine/unpack.c, determine_online_status_fencing() + [[ -z $in_ccm ]] && will_fence=true +- [[ $crmd = "banned" ]] && will_fence=true ++ [[ $join = "banned" ]] && will_fence=true + if [[ ${expected-down} = "down" && $in_ccm = "false" && $crmd != "online" ]]; then + : "pacemaker considers this as clean down" + elif [[ $in_ccm = false ]] || [[ $crmd != "online" ]]; then +diff --git a/scripts/crm-fence-peer.sh b/scripts/crm-fence-peer.sh +index 61e3145f..39329379 100755 +--- a/scripts/crm-fence-peer.sh ++++ b/scripts/crm-fence-peer.sh +@@ -607,7 +607,7 @@ guess_if_pacemaker_will_fence() + + # for further inspiration, see pacemaker:lib/pengine/unpack.c, determine_online_status_fencing() + [[ -z $in_ccm ]] && will_fence=true +- [[ $crmd = "banned" ]] && will_fence=true ++ [[ $join = "banned" ]] && will_fence=true + if [[ ${expected-down} = "down" && $in_ccm = "false" && $crmd != "online" ]]; then + : "pacemaker considers this as clean down" + elif [[ $in_ccm = false ]] || [[ $crmd != "online" ]]; then +-- +2.33.1.windows.1 + diff --git a/drbd.spec b/drbd.spec index 39fa11e..9e90767 100644 --- a/drbd.spec +++ b/drbd.spec @@ -1,7 +1,7 @@ Name: drbd Summary: DRBD user-land tools and scripts Version: 9.27.0 -Release: 8 +Release: 9 Source0: http://www.linbit.com/downloads/%{name}/utils/%{name}-utils-%{version}.tar.gz Patch0: drbd-utils-9.12.2-disable_xsltproc_network_read.patch Patch1: drbd-utils-9.15.0-make_configure-workaround.patch @@ -29,6 +29,10 @@ Patch12: backport-drbdsetup-add-udev-command.patch # https://github.com/LINBIT/drbd-utils/commit/18f80de3d9ff0da105353a96a232a486397a6049 Patch13: backport-drbd.rules-use-drbdsetup-udev-command.patch # https://github.com/LINBIT/drbd-utils/commit/aa640965755365ead255d5aca78c290e8a7de52a +Patch14: backport-crm-fence-peer.9.sh-fix-parsing-in_ccm-crmd-fields-o.patch +# https://github.com/LINBIT/drbd-utils/commit/7506d0ee973d93a90ae5e41e62c4693b5c4e954d +Patch15: backport-crm-fence-peer.9.sh-use-join-of-node_state-to-judge-.patch +# https://github.com/LINBIT/drbd-utils/commit/4ef967dd140cfd636574557133064ce2330540f8 License: GPL-2.0-or-later ExclusiveOS: linux @@ -239,6 +243,10 @@ management utility. %systemd_preun drbd.service %changelog +* Wed Jul 24 2024 liupei - 9.27.0-9 +- crm-fence-peer.9.sh: fix parsing in_ccm crmd fields of node_state with Pacemaker 2.1.7 +- crm-fence-peer.9.sh: use join of node_state to judge whether node is banned + * Mon Jul 15 2024 liupei - 9.27.0-8 - configure.ac: Add an option to disable host udev version checks - drbdsetup: add udev command -- Gitee