Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
From: Su Yue <glass.su@suse.com>
To: drbd-dev@lists.linbit.com
Cc: lars.ellenberg@linbit.com
Subject: [RFC PATCH 1/3] drbd.ocf: replace crm_master with ocf_promotion_score
Date: Mon, 29 Jul 2024 21:34:08 +0800	[thread overview]
Message-ID: <20240729133410.8332-2-glass.su@suse.com> (raw)
In-Reply-To: <20240729133410.8332-1-glass.su@suse.com>

The crm_master command has been deprecated and replaced with a new
crm_attribute --promotion option that defaults to --lifetime=reboot
(example: crm_master -l reboot -v 10 becomes
crm_attribute --promotion -v 10. The old command will still work for
now, but the new one should be used if available. The new option is
available as of CRM feature set 3.9.0).

Also define ocf_promotion_score() as
resource-agents/heartbeat/ocf-shellfuncs.in if it doesn't exist.

Signed-off-by: Su Yue <glass.su@suse.com>
---
 scripts/drbd.ocf | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/scripts/drbd.ocf b/scripts/drbd.ocf
index 1d051baa550d..133aff737455 100755
--- a/scripts/drbd.ocf
+++ b/scripts/drbd.ocf
@@ -104,6 +104,18 @@ if ! command -v ocf_is_true &> /dev/null ; then
 	}
 fi
 
+if ! command -v ocf_promotion_score &> /dev/null ; then
+	ocf_promotion_score() {
+		ocf_version_cmp "$OCF_RESKEY_crm_feature_set" "3.10.0"
+		res=$?
+		if [ $res -eq 2 ] || [ $res -eq 1 ] || ! have_binary "crm_master"; then
+			${HA_SBIN_DIR}/crm_attribute -p ${OCF_RESOURCE_INSTANCE} $@
+		else
+			${HA_SBIN_DIR}/crm_master -l reboot $@
+		fi
+	}
+fi
+
 # Defaults
 OCF_RESKEY_drbdconf_default="/etc/drbd.conf"
 OCF_RESKEY_unfence_extra_args_default="--quiet --flock-required --flock-timeout 0 --unfence-only-if-owner-match"
@@ -570,9 +582,9 @@ do_drbdadm() {
 unset current_master_score
 get_current_master_score()
 {
-	# only call crm_master once
+	# only call get crm master once
 	[[ ${current_master_score+set} ]] ||
-	current_master_score=$(crm_master -q -l reboot -G 2>/dev/null)
+	current_master_score=$(ocf_promotion_score -q -G 2>/dev/null)
 	# return value of this function:
 	# true if master_score is present
 	# false if master_score is not present
@@ -585,13 +597,13 @@ set_master_score() {
 	if [[ $1 -le 0 ]]; then
 		remove_master_score
 	else
-		do_cmd ${HA_SBIN_DIR}/crm_master -Q -l reboot -v $1 &&
+		do_cmd ocf_promotion_score -Q -v $1 &&
 		current_master_score=$1
 	fi
 }
 
 remove_master_score() {
-	do_cmd ${HA_SBIN_DIR}/crm_master -l reboot -D
+	do_cmd ocf_promotion_score -D
 	current_master_score=""
 }
 
-- 
2.45.2


  reply	other threads:[~2024-07-29 13:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29 13:34 [RFC PATCH 0/3] drbd.ocf support for OCF 1.1 standard Su Yue
2024-07-29 13:34 ` Su Yue [this message]
2024-07-29 13:34 ` [RFC PATCH 2/3] drbd.ocf: update regex of sed for new output from crm_resource Su Yue
2024-07-29 13:34 ` [RFC PATCH 3/3] drbd.ocf: update for OCF 1.1 Su Yue

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=20240729133410.8332-2-glass.su@suse.com \
    --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