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

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.1+20190417.13d370ca9/cts/cts-fencing.in
===================================================================
--- pacemaker-2.0.1+20190417.13d370ca9.orig/cts/cts-fencing.in
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/cts-fencing.in
@@ -1073,16 +1073,16 @@ class Tests(object):
             test.add_stonith_log_pattern(r"perform op 'node3 off' with '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 op 'node3 off' with '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 op 'node3 off' with '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.1+20190417.13d370ca9/daemons/fenced/fenced_remote.c
===================================================================
--- pacemaker-2.0.1+20190417.13d370ca9.orig/daemons/fenced/fenced_remote.c
+++ pacemaker-2.0.1+20190417.13d370ca9/daemons/fenced/fenced_remote.c
@@ -1252,8 +1252,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;
@@ -1268,7 +1269,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]);
@@ -1302,8 +1303,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);
     }
 }
 
@@ -1350,7 +1351,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 */
@@ -1507,7 +1509,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) {
@@ -1530,7 +1536,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_info("Requesting that '%s' perform op '%s %s' with '%s' for %s (%ds)", peer->host,
                      op->target, op->action, device, op->client_name, timeout_one);
             crm_xml_add(remote_op, F_STONITH_DEVICE, device);
openSUSE Build Service is sponsored by