Package: pacemaker / 2.1.5-1+deb12u1

Low-scheduler-unknown_on_node-should-ignore-pending-actio.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
From: Ken Gaillot <kgaillot@redhat.com>
Date: Thu, 2 Feb 2023 10:25:53 -0600
Subject: Low: scheduler: unknown_on_node() should ignore pending actions

Previously, unknown_on_node() looked for any lrm_rsc_op at all to decide
whether a resource is known on a node. However if the only action is pending,
the resource is not yet known.

Also drop a redundant argument and add a doxygen block. (The rsc argument is
not const due to a getDocPtr() call in the chain, as well as libxml2 calls that
are likely const in practice but aren't marked as such.)
---
 lib/pengine/unpack.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c
index 41cb980..e9fcae1 100644
--- a/lib/pengine/unpack.c
+++ b/lib/pengine/unpack.c
@@ -2654,19 +2654,32 @@ find_lrm_resource(const char *rsc_id, const char *node_name,
     return xml;
 }
 
+/*!
+ * \internal
+ * \brief Check whether a resource has no completed action history on a node
+ *
+ * \param[in,out] rsc        Resource to check
+ * \param[in]     node_name  Node to check
+ *
+ * \return true if \p rsc_id is unknown on \p node_name, otherwise false
+ */
 static bool
-unknown_on_node(const char *rsc_id, const char *node_name,
-                pe_working_set_t *data_set)
+unknown_on_node(pe_resource_t *rsc, const char *node_name)
 {
-    xmlNode *lrm_resource = NULL;
-
-    lrm_resource = find_lrm_resource(rsc_id, node_name, data_set);
+    bool result = false;
+    xmlXPathObjectPtr search;
+    GString *xpath = g_string_sized_new(256);
 
-    /* If the resource has no lrm_rsc_op history on the node, that means its
-     * state is unknown there.
-     */
-    return (lrm_resource == NULL
-            || first_named_child(lrm_resource, XML_LRM_TAG_RSC_OP) == NULL);
+    pcmk__g_strcat(xpath,
+                   XPATH_NODE_STATE "[@" XML_ATTR_UNAME "='", node_name, "']"
+                   SUB_XPATH_LRM_RESOURCE "[@" XML_ATTR_ID "='", rsc->id, "']"
+                   SUB_XPATH_LRM_RSC_OP "[@" XML_LRM_ATTR_RC "!='193']",
+                   NULL);
+    search = xpath_search(rsc->cluster->input, (const char *) xpath->str);
+    result = (numXpathResults(search) == 0);
+    freeXpathObject(search);
+    g_string_free(xpath, TRUE);
+    return result;
 }
 
 /*!
@@ -2979,7 +2992,7 @@ unpack_migrate_to_failure(pe_resource_t *rsc, pe_node_t *node, xmlNode *xml_op,
          * Don't just consider it running there. We will get back here anyway in
          * case the probe detects it's running there.
          */
-        !unknown_on_node(rsc->id, target, data_set)
+        !unknown_on_node(rsc, target)
         /* If the resource has newer state on the target after the migration
          * events, this migrate_to no longer matters for the target.
          */
@@ -3031,7 +3044,7 @@ unpack_migrate_from_failure(pe_resource_t *rsc, pe_node_t *node,
          * Don't just consider it running there. We will get back here anyway in
          * case the probe detects it's running there.
          */
-        !unknown_on_node(rsc->id, source, data_set)
+        !unknown_on_node(rsc, source)
         /* If the resource has newer state on the source after the migration
          * events, this migrate_from no longer matters for the source.
          */