File 0001-Fix-agents-handle-dampening-parameter-consistently-a.patch of Package pacemaker.34782

From 1f8e3d6ff66f474c215b4c56f480512e12b08f87 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 5 Dec 2023 13:52:05 -0600
Subject: [PATCH] Fix: agents: handle dampening parameter consistently and
 correctly

Always quote variable when used (in case value incorrectly contains
whitespace), always use attrd_updater -B instead of -U to ensure dampening is
truly reloadable, and always mark parameter as reloadable in metadata.

Also, dampening doesn't need to be passed with attrd_updater -D.
---
 extra/resources/HealthCPU      |  9 ++++-----
 extra/resources/HealthSMART.in | 16 ++++++++--------
 extra/resources/ifspeed.in     | 20 ++++++++++++--------
 extra/resources/ping           | 13 ++++---------
 4 files changed, 28 insertions(+), 30 deletions(-)

Index: pacemaker-2.0.5+20201202.ba59be712/extra/resources/HealthSMART.in
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/extra/resources/HealthSMART.in
+++ pacemaker-2.0.5+20201202.ba59be712/extra/resources/HealthSMART.in
@@ -110,25 +110,25 @@ check_temperature() {
 
     if [ $1 -lt ${lower_red_limit} ] ; then
         ocf_log info "Drive ${DRIVE} ${DEVICE} too cold: ${1} C"
-        "$ATTRDUP" -n "#health-smart" -U "red" -d "5s"
+        "$ATTRDUP" -n "#health-smart" -B "red" -d "5s"
         return 1
     fi
 
     if [ $1 -gt ${upper_red_limit} ] ; then
         ocf_log info "Drive ${DRIVE} ${DEVICE} too hot: ${1} C"
-        "$ATTRDUP" -n "#health-smart" -U "red" -d "5s"
+        "$ATTRDUP" -n "#health-smart" -B "red" -d "5s"
         return 1
     fi
 
     if [ $1 -lt ${lower_yellow_limit} ] ; then
         ocf_log info "Drive ${DRIVE} ${DEVICE} quite cold: ${1} C"
-        "$ATTRDUP" -n "#health-smart" -U "yellow" -d "5s"
+        "$ATTRDUP" -n "#health-smart" -B "yellow" -d "5s"
         return 1
     fi
 
     if [ $1 -gt ${upper_yellow_limit} ] ; then
         ocf_log info "Drive ${DRIVE} ${DEVICE} quite hot: ${1} C"
-        "$ATTRDUP" -n "#health-smart" -U "yellow" -d "5s"
+        "$ATTRDUP" -n "#health-smart" -B "yellow" -d "5s"
         return 1
     fi
 }
@@ -206,6 +206,9 @@ HealthSMART_start() {
 
 HealthSMART_stop() {
     HealthSMART_monitor
+
+    "$ATTRDUP" -D -n "#health-smart"
+
     if [ $? -eq $OCF_SUCCESS ]; then
         rm "${OCF_RESKEY_state}"
     fi
@@ -228,14 +231,14 @@ HealthSMART_monitor() {
                 for DEVICE in ${OCF_RESKEY_devices}; do
                     "$SMARTCTL" -d "$DEVICE" -H ${DRIVE} | grep -q "SMART overall-health self-assessment test result: PASSED"
                     if [ $? -ne 0 ]; then
-                        "$ATTRDUP" -n "#health-smart" -U "red" -d "5s"
+                        "$ATTRDUP" -n "#health-smart" -B "red" -d "5s"
                         return $OCF_SUCCESS
                     fi
                 done
             else
                 "$SMARTCTL" -H "${DRIVE}" | grep -q "SMART overall-health self-assessment test result: PASSED"
                 if [ $? -ne 0 ]; then
-                    "$ATTRDUP" -n "#health-smart" -U "red" -d "5s"
+                    "$ATTRDUP" -n "#health-smart" -B "red" -d "5s"
                     return $OCF_SUCCESS
                 fi
             fi
@@ -256,7 +259,7 @@ HealthSMART_monitor() {
             fi
         done
 
-        "$ATTRDUP" -n "#health-smart" -U "green" -d "5s"
+        "$ATTRDUP" -n "#health-smart" -B "green" -d "5s"
         return $OCF_SUCCESS
     fi
 
Index: pacemaker-2.0.5+20201202.ba59be712/extra/resources/ifspeed.in
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/extra/resources/ifspeed.in
+++ pacemaker-2.0.5+20201202.ba59be712/extra/resources/ifspeed.in
@@ -185,7 +185,7 @@ start() {
 
 stop() {
     ha_pseudo_resource "${ha_pseudo_resource_name}" stop
-    attrd_updater -D -n "${OCF_RESKEY_name}" -d "${OCF_RESKEY_dampen}" ${attrd_options}
+    attrd_updater -D -n "${OCF_RESKEY_name}" ${attrd_options}
     return $OCF_SUCCESS
 }
 
@@ -485,11 +485,7 @@ update() {
     speed=$( iface_get_speed "${nic}" )
 
     : $(( score = speed * ${OCF_RESKEY_weight_base} / 1000 ))
-    if [ "$__OCF_ACTION" = "start" ] ; then
-        attrd_updater -n "${OCF_RESKEY_name}" -B "${score}" -d "${OCF_RESKEY_dampen}" ${attrd_options}
-    else
-        attrd_updater -n "${OCF_RESKEY_name}" -v "${score}" -d "${OCF_RESKEY_dampen}" ${attrd_options}
-    fi
+    attrd_updater -n "${OCF_RESKEY_name}" -B "${score}" -d "${OCF_RESKEY_dampen}" ${attrd_options}
     rc=$?
     case ${rc} in
         0)
Index: pacemaker-2.0.5+20201202.ba59be712/extra/resources/ping
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/extra/resources/ping
+++ pacemaker-2.0.5+20201202.ba59be712/extra/resources/ping
@@ -164,7 +164,7 @@ ping_stop() {
 
     rm -f "${OCF_RESKEY_pidfile}"
 
-    attrd_updater -D -n "$OCF_RESKEY_name" -d "$OCF_RESKEY_dampen" $attrd_options
+    attrd_updater -D -n "$OCF_RESKEY_name" $attrd_options
 
     return $OCF_SUCCESS
 }
@@ -287,11 +287,7 @@ ping_update() {
     fi
 
     score=$(expr $active \* $OCF_RESKEY_multiplier)
-    if [ "$__OCF_ACTION" = "start" ] ; then
-        attrd_updater -n "$OCF_RESKEY_name" -B "$score" -d "$OCF_RESKEY_dampen" $attrd_options
-    else
-        attrd_updater -n "$OCF_RESKEY_name" -v "$score" -d "$OCF_RESKEY_dampen" $attrd_options
-    fi
+    attrd_updater -n "$OCF_RESKEY_name" -B "$score" -d "$OCF_RESKEY_dampen" $attrd_options
     rc=$?
     case $rc in
         0) ping_conditional_log debug "Updated $OCF_RESKEY_name = $score" ;;
openSUSE Build Service is sponsored by