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

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.1.5+20221208.a3f44794f/cts/cts-fencing.in
===================================================================
--- pacemaker-2.1.5+20221208.a3f44794f.orig/cts/cts-fencing.in
+++ pacemaker-2.1.5+20221208.a3f44794f/cts/cts-fencing.in
@@ -1232,16 +1232,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 using true1 for 2s | timeout=121s requested_delay=1s base=1s max=1s")
+            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 using 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 using false1 for 1s | timeout=121s requested_delay=0s base=1s max=1s")
+            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 using 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 using true2 for 1s | timeout=122s requested_delay=0s base=1s max=2s")
+            test.add_stonith_log_pattern("Delaying 'off' action targeting node3 using true2 for 1s | timeout=120s requested_delay=0s base=1s max=2s")
 
             test.add_stonith_neg_log_pattern("Delaying 'off' action targeting node3 using true3")
 
Index: pacemaker-2.1.5+20221208.a3f44794f/daemons/fenced/fenced_remote.c
===================================================================
--- pacemaker-2.1.5+20221208.a3f44794f.orig/daemons/fenced/fenced_remote.c
+++ pacemaker-2.1.5+20221208.a3f44794f/daemons/fenced/fenced_remote.c
@@ -1462,7 +1462,8 @@ stonith_choose_peer(remote_fencing_op_t
 
 static int
 get_device_timeout(const remote_fencing_op_t *op,
-                   const peer_device_info_t *peer, const char *device)
+                   const peer_device_info_t *peer, const char *device,
+                   bool with_delay)
 {
     device_properties_t *props;
     int delay = 0;
@@ -1477,7 +1478,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]);
@@ -1511,8 +1512,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);
     }
 }
 
@@ -1586,7 +1587,8 @@ get_op_total_timeout(const remote_fencin
                     if (find_peer_device(op, peer, device_list->data,
                                          fenced_support_flag(op->action))) {
                         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 */
@@ -1601,7 +1603,8 @@ get_op_total_timeout(const remote_fencin
                 for (iter2 = op->query_results; iter2 != NULL; iter = iter2->next) {
                     peer_device_info_t *peer = iter2->data;
                     if (find_peer_device(op, peer, iter->data, st_device_supports_on)) {
-                        total_timeout += get_device_timeout(op, peer, iter->data);
+                        total_timeout += get_device_timeout(op, peer,
+                                                            iter->data, true);
                         break;
                     }
                 }
@@ -1836,7 +1839,11 @@ request_peer_fencing(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) {
@@ -1859,7 +1866,7 @@ request_peer_fencing(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