File bsc#1210074-0011-Fix-fencer-fencing-timeout-sent-to-peer-takes-no-del.patch of Package pacemaker.34782

From 65a938c2e24d8d6be75fac04ae99eedef4cd99e2 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Mon, 17 Apr 2023 19:01:25 +0200
Subject: [PATCH 11/11] Fix: fencer: fencing timeout sent to peer takes no
 delay into account

The peer will add a dedicated timer for any delay upon
schedule_stonith_command().
---
 cts/cts-fencing.in             |  6 +++---
 daemons/fenced/fenced_remote.c | 23 +++++++++++++++--------
 2 files changed, 18 insertions(+), 11 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
@@ -1159,16 +1159,16 @@ class Tests(object):
             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=121s, requested_delay=1s, base=1s, max=1s)")
+            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 on true1 for 2s (timeout=120s, 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=121s, requested_delay=0s, base=1s, max=1s)")
+            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 on false1 for 1s (timeout=120s, 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'")
-            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 on true2 for 1s (timeout=122s, requested_delay=0s, base=1s, max=2s)")
+            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 on true2 for 1s (timeout=120s, requested_delay=0s, base=1s, max=2s)")
 
             test.add_stonith_neg_log_pattern("Delaying 'off' action targeting node3 on true3")
 
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
@@ -1288,8 +1288,9 @@ stonith_choose_peer(remote_fencing_op_t
 }
 
 static int
-get_device_timeout(const remote_fencing_op_t *op, const st_query_result_t *peer,
-                   const char *device)
+get_device_timeout(const remote_fencing_op_t *op,
+                   const st_query_result_t *peer, const char *device,
+                   bool with_delay)
 {
     device_properties_t *props;
     int delay = 0;
@@ -1304,7 +1305,7 @@ get_device_timeout(const remote_fencing_
     }
 
     // op->delay < 0 means disable any static/random fencing delays
-    if (op->delay >= 0) {
+    if (with_delay && 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]);
@@ -1338,8 +1339,8 @@ add_device_timeout(gpointer key, gpointe
 
     if (!props->executed[timeout->op->phase]
         && !props->disallowed[timeout->op->phase]) {
-        timeout->total_timeout += get_device_timeout(timeout->op,
-                                                     timeout->peer, device_id);
+        timeout->total_timeout += get_device_timeout(timeout->op, timeout->peer,
+                                                     device_id, true);
     }
 }
 
@@ -1386,7 +1387,8 @@ get_op_total_timeout(const remote_fencin
 
                     if (find_peer_device(op, peer, device_list->data)) {
                         total_timeout += get_device_timeout(op, peer,
-                                                            device_list->data);
+                                                            device_list->data,
+                                                            true);
                         break;
                     }
                 }               /* End Loop3: match device with peer that owns device, find device's timeout period */
@@ -1544,7 +1546,11 @@ call_remote_stonith(remote_fencing_op_t
         peer = stonith_choose_peer(op);
 
         device = op->devices->data;
-        timeout = get_device_timeout(op, peer, device);
+        /* Fencing timeout sent to peer takes no delay into account.
+         * The peer will add a dedicated timer for any delay upon
+         * schedule_stonith_command().
+         */
+        timeout = get_device_timeout(op, peer, device, false);
     }
 
     if (peer) {
@@ -1567,7 +1573,7 @@ call_remote_stonith(remote_fencing_op_t
 
         if (device) {
             timeout_one += TIMEOUT_MULTIPLY_FACTOR *
-                           get_device_timeout(op, peer, device);
+                           get_device_timeout(op, peer, device, true);
             crm_notice("Requesting that %s perform '%s' action targeting %s "
                        "using '%s' " CRM_XS " for client %s (%ds)",
                        peer->host, op->action, op->target, device,
openSUSE Build Service is sponsored by