File pacemaker#3772-0002-Fix-libpacemaker-set-fail-count-to-INFINITY-for-fata.patch of Package pacemaker.38496

From 54759f1d0484592c7090b06a8588d486889575ce Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Thu, 28 Nov 2024 18:17:09 +0100
Subject: [PATCH 2/2] Fix: libpacemaker: set fail-count to INFINITY for fatal
 failures

... to be consistent with what controller does with update_failcount()
---
 lib/pacemaker/libpacemaker_private.h |  3 ++-
 lib/pacemaker/pcmk_sched_transition.c      | 25 ++++++++++++++++++++++---
 lib/pacemaker/pcmk_sched_transition.c        | 13 ++++++++++++-
 3 files changed, 36 insertions(+), 5 deletions(-)

Index: pacemaker-2.1.2+20211124.ada5c3b36/lib/pacemaker/pcmk_sched_transition.c
===================================================================
--- pacemaker-2.1.2+20211124.ada5c3b36.orig/lib/pacemaker/pcmk_sched_transition.c
+++ pacemaker-2.1.2+20211124.ada5c3b36/lib/pacemaker/pcmk_sched_transition.c
@@ -68,7 +68,7 @@ inject_transient_attr(xmlNode * cib_node
 static void
 update_failcounts(cib_t *cib_conn, xmlNode *cib_node,
                        const char *resource, const char *task,
-                       guint interval_ms, int exit_status)
+                       guint interval_ms, int exit_status, bool infinity)
 {
     char *name = NULL;
     char *value = NULL;
@@ -96,7 +96,13 @@ update_failcounts(cib_t *cib_conn, xmlNo
     }
     free(value);
 
-    value = pcmk__itoa(failcount + 1);
+    if (infinity) {
+        value = strdup(CRM_INFINITY_S);
+
+    } else {
+        value = pcmk__itoa(failcount + 1);
+    }
+
     inject_transient_attr(cib_node, name, value);
 
     free(name);
@@ -609,6 +615,8 @@ modify_configuration(pe_working_set_t *
         if (rsc == NULL) {
             out->err(out, "Invalid resource name: %s", resource);
         } else {
+            bool infinity = false;
+
             rclass = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
             rtype = crm_element_value(rsc->xml, XML_ATTR_TYPE);
             rprovider = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER);
@@ -616,8 +624,17 @@ modify_configuration(pe_working_set_t *
             cib_node = inject_node_state(cib, node, NULL);
             CRM_ASSERT(cib_node != NULL);
 
+            if (pcmk__str_eq(task, CRMD_ACTION_STOP, pcmk__str_none)) {
+                infinity = true;
+
+            } else if (pcmk__str_eq(task, CRMD_ACTION_START, pcmk__str_none)
+                       && pcmk_is_set(data_set->flags,
+                                      pe_flag_start_failure_fatal)) {
+                infinity = true;
+            }
+
             update_failcounts(cib, cib_node, resource, task, interval_ms,
-                              outcome);
+                              outcome, infinity);
 
             cib_resource = inject_resource(cib_node, resource, resource,
                                            rclass, rtype, rprovider);
@@ -761,6 +778,7 @@ exec_rsc_action(crm_graph_t * graph, crm
         }
 
         if (match_name != NULL) {
+            const char *offset = NULL;
 
             rc = sscanf(spec, "%*[^=]=%d", (int *) &op->rc);
             // ${match_name}_${task}_${interval_in_ms}@${node}=${rc}
@@ -774,8 +792,18 @@ exec_rsc_action(crm_graph_t * graph, crm
             crm__set_graph_action_flags(action, pcmk__graph_action_failed);
             graph->abort_priority = INFINITY;
             out->info(out, "Pretending action %d failed with rc=%d", action->id, op->rc);
+
+            if (pcmk__str_eq(op->op_type, CRMD_ACTION_START, pcmk__str_none)) {
+                offset = CRM_INFINITY_S;
+
+            } else if (pcmk__str_eq(op->op_type, CRMD_ACTION_STOP,
+                                    pcmk__str_none)) {
+                offset = CRM_INFINITY_S;
+            }
+
             update_failcounts(fake_cib, cib_node, match_name, op->op_type,
-                              op->interval_ms, op->rc);
+                              op->interval_ms, op->rc,
+                              pcmk_str_is_infinity(offset));
             break;
         }
     }
openSUSE Build Service is sponsored by