File crm-fence-peer-pacemaker2-issue2.patch of Package drbd-utils.18415

This patch bsc#1176065 is based on upstream patch cca7e28f6,
crm-fence-peer: just ignore master vs promotable clone issues
Cause when crm_feature_set=3.1, still able to use master

With the original patch, will have error msg:
sed: -e expression #1, char 28: unknown command: `\'
WARNING drbd-fencing could not determine the master id of drbd resource xxx

Either replace the '\\' to '\' or change back to the original "xxx"'
quotation could fix the error.

diff -Naur drbd-utils-9.6.0.orig/scripts/crm-fence-peer.9.sh drbd-utils-9.6.0/scripts/crm-fence-peer.9.sh
--- drbd-utils-9.6.0.orig/scripts/crm-fence-peer.9.sh	2020-09-04 10:17:24.831007451 +0800
+++ drbd-utils-9.6.0/scripts/crm-fence-peer.9.sh	2020-09-04 10:19:13.959824826 +0800
@@ -200,12 +200,9 @@
 
 	# with Pacemaker 2, its "promotable clones" instead of the
 	# "master" (which was deemed a bad naming choice).
-	# detect older pacemaker by crm_feature_set < 3.1.0
-	local clone_or_master=clone
-	case $crm_feature_set in
-		3.0.*|[012].*)	: "pacemaker version < 2, master slave"
-			clone_or_master=master ;;
-	esac
+	# newer pacemaker does stil understand and may still use the old xml, though,
+	# and it is rather cumbersome to detect which is in use.
+	# just try both
 
 	# cibadmin -Ql --xpath \
 	# '//master[primitive[@type="drbd" and instance_attributes/nvpair[@name = "drbd_resource" and @value="r0"]]]/@id'
@@ -217,8 +214,8 @@
 	# or double check that it is in fact a promotable="true" clone...
 	# But in the real world, this is good enough.
 	: ${master_id=$(set +x; echo "$cib_xml" |
-		sed -ne "/<$clone_or_master /,/<\\/$clone_or_master>/ {
-			   /<$clone_or_master / h;"'
+		sed -ne '/<\(clone\|master\) /,/<\/\(clone\|master\)>/ {
+			   /<\(clone\|master\) / h;
 			     /<primitive/,/<\/primitive/ {
 			       /<instance_attributes/,/<\/instance_attributes/ {
 				 /<nvpair .*\bname="drbd_resource"/ {
diff -Naur drbd-utils-9.6.0.orig/scripts/crm-fence-peer.sh drbd-utils-9.6.0/scripts/crm-fence-peer.sh
--- drbd-utils-9.6.0.orig/scripts/crm-fence-peer.sh	2020-09-04 10:17:24.831007451 +0800
+++ drbd-utils-9.6.0/scripts/crm-fence-peer.sh	2020-09-04 10:21:59.481075311 +0800
@@ -54,12 +54,9 @@
 
 	# with Pacemaker 2, its "promotable clones" instead of the
 	# "master" (which was deemed a bad naming choice).
-	# detect older pacemaker by crm_feature_set < 3.1.0
-	local clone_or_master=clone
-	case $crm_feature_set in
-		3.0.*|[012].*)	: "pacemaker version < 2, master slave"
-			clone_or_master=master ;;
-	esac
+	# newer pacemaker does stil understand and may still use the old xml, though,
+	# and it is rather cumbersome to detect which is in use.
+	# just try both
 
 	# cibadmin -Ql --xpath \
 	# '//master[primitive[@type="drbd" and instance_attributes/nvpair[@name = "drbd_resource" and @value="r0"]]]/@id'
@@ -71,8 +68,8 @@
 	# or double check that it is in fact a promotable="true" clone...
 	# But in the real world, this is good enough.
 	: ${master_id=$(set +x; echo "$cib_xml" |
-		sed -ne "/<$clone_or_master /,/<\\/$clone_or_master>/ {
-			   /<$clone_or_master / h;"'
+		sed -ne '/<\(clone\|master\) /,/<\/\(clone\|master\)>/ {
+			   /<\(clone\|master\) / h;
 			     /<primitive/,/<\/primitive/ {
 			       /<instance_attributes/,/<\/instance_attributes/ {
 				 /<nvpair .*\bname="drbd_resource"/ {
openSUSE Build Service is sponsored by