From: Su Yue <glass.su@suse.com>
To: drbd-dev@lists.linbit.com
Cc: lars.ellenberg@linbit.com
Subject: [PATCH 1/2] crm-fence-peer.9.sh: fix parsing in_ccm crmd fields of node_state with Pacemaker 2.1.7
Date: Sun, 3 Mar 2024 17:12:58 +0800 [thread overview]
Message-ID: <20240303091259.5045-1-l@damenly.org> (raw)
From: Su Yue <glass.su@suse.com>
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 <glass.su@suse.com>
---
scripts/crm-fence-peer.9.sh | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/scripts/crm-fence-peer.9.sh b/scripts/crm-fence-peer.9.sh
index 44da6516bf3f..a3353a7354a6 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 ::= <timestamp>|0
+ # Since when node has been a cluster member. A value 0 of means the
+ # node is not a cluster member.
+ # - crmd ::= <timestamp>|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.44.0
next reply other threads:[~2024-03-03 9:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-03 9:12 Su Yue [this message]
2024-03-03 9:12 ` [PATCH 2/2] crm-fence-peer.9.sh: use join of node_state to judge whether node is banned Su Yue
2024-03-07 2:54 ` Su Yue
2024-03-14 3:18 ` Su Yue
2024-04-17 9:57 ` Lars Ellenberg
2024-04-17 10:47 ` Glass Su
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240303091259.5045-1-l@damenly.org \
--to=glass.su@suse.com \
--cc=drbd-dev@lists.linbit.com \
--cc=lars.ellenberg@linbit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox