File bsc#1210074-0005-Fix-fencer-fencing-timeouts-take-any-pcmk_delay_base.patch of Package pacemaker.29789

From d2123dac8491e368b1d3f55d103cbd9ccad76412 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Thu, 13 Apr 2023 13:05:22 +0200
Subject: [PATCH 05/11] Fix: fencer: fencing timeouts take any pcmk_delay_base
 into account

... to prevent it from eating up the timeouts.

Fixes T93
Fixes CLBZ#5493
---
 cts/cts-fencing.in             | 10 +++++-----
 daemons/fenced/fenced_remote.c | 12 ++++++++++--
 2 files changed, 15 insertions(+), 7 deletions(-)

Index: pacemaker-2.0.5+20201202.ba59be712/cts/cts-fencing.in
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/cts/cts-fencing.in
+++ pacemaker-2.0.5+20201202.ba59be712/cts/cts-fencing.in
@@ -1152,19 +1152,19 @@ class Tests(object):
             test.add_cmd("stonith_admin", "--output-as=xml -F node3 --delay 1")
 
             # Total fencing timeout takes all fencing delays into account.
-            test.add_stonith_log_pattern("Total timeout set to 579")
+            test.add_stonith_log_pattern("Total timeout set to 582")
 
             # Fencing timeout for the first device takes the requested fencing delay into account.
             # Fencing timeout also takes pcmk_delay_base into account.
             test.add_stonith_log_pattern(r"perform 'off' action targeting node3 using 'true1'")
             # Requested fencing delay is applied only for the first device in the first level.
             # Static delay from pcmk_delay_base is added.
-            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 on true1 for 2s (timeout=120s, requested_delay=1s, base=1s, max=1s)")
+            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 on true1 for 2s (timeout=121s, requested_delay=1s, base=1s, max=1s)")
 
             # Fencing timeout no longer takes the requested fencing delay into account for further devices.
             test.add_stonith_log_pattern(r"perform 'off' action targeting node3 using 'false1'")
             # Requested fencing delay is no longer applied for further devices.
-            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 on false1 for 1s (timeout=120s, requested_delay=0s, base=1s, max=1s)")
+            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 on false1 for 1s (timeout=121s, requested_delay=0s, base=1s, max=1s)")
 
             # Fencing timeout takes pcmk_delay_max into account.
             test.add_stonith_log_pattern(r"perform 'off' action targeting node3 using 'true2'")
Index: pacemaker-2.0.5+20201202.ba59be712/daemons/fenced/fenced_remote.c
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/daemons/fenced/fenced_remote.c
+++ pacemaker-2.0.5+20201202.ba59be712/daemons/fenced/fenced_remote.c
@@ -1283,6 +1283,7 @@ get_device_timeout(const remote_fencing_
                    const char *device)
 {
     device_properties_t *props;
+    int delay = 0;
 
     if (!peer || !device) {
         return op->base_timeout;
@@ -1293,9 +1294,16 @@ get_device_timeout(const remote_fencing_
         return op->base_timeout;
     }
 
+    // op->delay < 0 means disable any static/random fencing delays
+    if (op->delay >= 0) {
+        // delay_base is eventually limited by delay_max
+        delay = (props->delay_max[op->phase] > 0 ?
+                 props->delay_max[op->phase] : props->delay_base[op->phase]);
+    }
+
     return (props->custom_action_timeout[op->phase]?
-           props->custom_action_timeout[op->phase] : op->base_timeout)
-           + props->delay_max[op->phase];
+            props->custom_action_timeout[op->phase] : op->base_timeout)
+           + delay;
 }
 
 struct timeout_data {
openSUSE Build Service is sponsored by