Skip to content

Commit 7c29b2d

Browse files
authored
Merge pull request #3839 from nrwahl2/nrwahl2-pengine
Update interfaces of pcmk__rsc_methods_t functions
2 parents 0ab5c4d + f3339c8 commit 7c29b2d

File tree

16 files changed

+171
-206
lines changed

16 files changed

+171
-206
lines changed

include/crm/common/resources_internal.h

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 the Pacemaker project contributors
2+
* Copyright 2024-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -10,6 +10,7 @@
1010
#ifndef PCMK__CRM_COMMON_RESOURCES_INTERNAL__H
1111
#define PCMK__CRM_COMMON_RESOURCES_INTERNAL__H
1212

13+
#include <stdbool.h> // bool
1314
#include <stdint.h> // uint32_t
1415
#include <glib.h> // gboolean, gpointer, guint, etc.
1516
#include <libxml/tree.h> // xmlNode
@@ -182,12 +183,11 @@ typedef struct {
182183
* \internal
183184
* \brief Parse variant-specific resource XML from CIB into struct members
184185
*
185-
* \param[in,out] rsc Partially unpacked resource
186-
* \param[in,out] scheduler Scheduler data
186+
* \param[in,out] rsc Partially unpacked resource
187187
*
188-
* \return TRUE if resource was unpacked successfully, otherwise FALSE
188+
* \return \c true if resource was unpacked successfully, otherwise \c false
189189
*/
190-
gboolean (*unpack)(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
190+
bool (*unpack)(pcmk_resource_t *rsc);
191191

192192
/*!
193193
* \internal
@@ -201,23 +201,7 @@ typedef struct {
201201
* \return Resource that matches search criteria if any, otherwise NULL
202202
*/
203203
pcmk_resource_t *(*find_rsc)(pcmk_resource_t *rsc, const char *search,
204-
const pcmk_node_t *node, int flags);
205-
206-
/*!
207-
* \internal
208-
* \brief Get value of a resource instance attribute
209-
*
210-
* \param[in,out] rsc Resource to check
211-
* \param[in] node Node to use to evaluate rules
212-
* \param[in] create Ignored
213-
* \param[in] name Name of instance attribute to check
214-
* \param[in,out] scheduler Scheduler data
215-
*
216-
* \return Value of requested attribute if available, otherwise NULL
217-
* \note The caller is responsible for freeing the result using free().
218-
*/
219-
char *(*parameter)(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create,
220-
const char *name, pcmk_scheduler_t *scheduler);
204+
const pcmk_node_t *node, uint32_t flags);
221205

222206
/*!
223207
* \internal
@@ -228,18 +212,19 @@ typedef struct {
228212
*
229213
* \return TRUE if \p rsc is active, otherwise FALSE
230214
*/
231-
gboolean (*active)(pcmk_resource_t *rsc, gboolean all);
215+
bool (*active)(const pcmk_resource_t *rsc, bool all);
232216

233217
/*!
234218
* \internal
235219
* \brief Get resource's current or assigned role
236220
*
237221
* \param[in] rsc Resource to check
238-
* \param[in] current If TRUE, check current role, otherwise assigned role
222+
* \param[in] current If \c true, check current role; otherwise, check
223+
* assigned role
239224
*
240225
* \return Current or assigned role of \p rsc
241226
*/
242-
enum rsc_role_e (*state)(const pcmk_resource_t *rsc, gboolean current);
227+
enum rsc_role_e (*state)(const pcmk_resource_t *rsc, bool current);
243228

244229
/*!
245230
* \internal
@@ -280,13 +265,13 @@ typedef struct {
280265
*
281266
* \param[in] rsc Resource ID to check for
282267
* \param[in] only_rsc List of resource IDs to check
283-
* \param[in] check_parent If TRUE, check top ancestor as well
268+
* \param[in] check_parent If \c true, check top ancestor as well
284269
*
285-
* \return TRUE if \p rsc, its top parent if requested, or '*' is in
286-
* \p only_rsc, otherwise FALSE
270+
* \return \c true if \p rsc, its top parent if requested, or \c "*" is in
271+
* \p only_rsc, or \c false otherwise
287272
*/
288-
gboolean (*is_filtered)(const pcmk_resource_t *rsc, GList *only_rsc,
289-
gboolean check_parent);
273+
bool (*is_filtered)(const pcmk_resource_t *rsc, const GList *only_rsc,
274+
bool check_parent);
290275

291276
/*!
292277
* \internal

include/crm/pengine/internal.h

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2004-2024 the Pacemaker project contributors
2+
* Copyright 2004-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -11,7 +11,7 @@
1111
#define PCMK__CRM_PENGINE_INTERNAL__H
1212

1313
#include <stdbool.h>
14-
#include <stdint.h>
14+
#include <stdint.h> // uint32_t
1515
#include <string.h>
1616
#include <crm/common/xml.h>
1717
#include <crm/pengine/status.h>
@@ -58,25 +58,23 @@ void pe__create_promotable_pseudo_ops(pcmk_resource_t *clone,
5858

5959
bool pe_can_fence(const pcmk_scheduler_t *scheduler, const pcmk_node_t *node);
6060

61-
char *native_parameter(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create,
62-
const char *name, pcmk_scheduler_t *scheduler);
6361
pcmk_node_t *native_location(const pcmk_resource_t *rsc, GList **list,
6462
uint32_t target);
6563
void native_add_running(pcmk_resource_t *rsc, pcmk_node_t *node,
6664
pcmk_scheduler_t *scheduler, gboolean failed);
6765

68-
gboolean native_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
69-
gboolean group_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
70-
gboolean clone_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
71-
gboolean pe__unpack_bundle(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
66+
bool native_unpack(pcmk_resource_t *rsc);
67+
bool group_unpack(pcmk_resource_t *rsc);
68+
bool clone_unpack(pcmk_resource_t *rsc);
69+
bool pe__unpack_bundle(pcmk_resource_t *rsc);
7270

7371
pcmk_resource_t *native_find_rsc(pcmk_resource_t *rsc, const char *id,
74-
const pcmk_node_t *node, int flags);
72+
const pcmk_node_t *node, uint32_t flags);
7573

76-
gboolean native_active(pcmk_resource_t *rsc, gboolean all);
77-
gboolean group_active(pcmk_resource_t *rsc, gboolean all);
78-
gboolean clone_active(pcmk_resource_t *rsc, gboolean all);
79-
gboolean pe__bundle_active(pcmk_resource_t *rsc, gboolean all);
74+
bool native_active(const pcmk_resource_t *rsc, bool all);
75+
bool group_active(const pcmk_resource_t *rsc, bool all);
76+
bool clone_active(const pcmk_resource_t *rsc, bool all);
77+
bool pe__bundle_active(const pcmk_resource_t *rsc, bool all);
8078

8179
gchar *pcmk__native_output_string(const pcmk_resource_t *rsc, const char *name,
8280
const pcmk_node_t *node, uint32_t show_opts,
@@ -113,14 +111,11 @@ void group_free(pcmk_resource_t *rsc);
113111
void clone_free(pcmk_resource_t *rsc);
114112
void pe__free_bundle(pcmk_resource_t *rsc);
115113

116-
enum rsc_role_e native_resource_state(const pcmk_resource_t *rsc,
117-
gboolean current);
118-
enum rsc_role_e group_resource_state(const pcmk_resource_t *rsc,
119-
gboolean current);
120-
enum rsc_role_e clone_resource_state(const pcmk_resource_t *rsc,
121-
gboolean current);
114+
enum rsc_role_e native_resource_state(const pcmk_resource_t *rsc, bool current);
115+
enum rsc_role_e group_resource_state(const pcmk_resource_t *rsc, bool current);
116+
enum rsc_role_e clone_resource_state(const pcmk_resource_t *rsc, bool current);
122117
enum rsc_role_e pe__bundle_resource_state(const pcmk_resource_t *rsc,
123-
gboolean current);
118+
bool current);
124119

125120
void pe__count_common(pcmk_resource_t *rsc);
126121
void pe__count_bundle(pcmk_resource_t *rsc);
@@ -368,14 +363,14 @@ GList * pe__build_rsc_list(pcmk_scheduler_t *scheduler, const char *s);
368363

369364
bool pcmk__rsc_filtered_by_node(pcmk_resource_t *rsc, GList *only_node);
370365

371-
gboolean pe__bundle_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
372-
gboolean check_parent);
373-
gboolean pe__clone_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
374-
gboolean check_parent);
375-
gboolean pe__group_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
376-
gboolean check_parent);
377-
gboolean pe__native_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
378-
gboolean check_parent);
366+
bool pe__bundle_is_filtered(const pcmk_resource_t *rsc, const GList *only_rsc,
367+
bool check_parent);
368+
bool pe__clone_is_filtered(const pcmk_resource_t *rsc, const GList *only_rsc,
369+
bool check_parent);
370+
bool pe__group_is_filtered(const pcmk_resource_t *rsc, const GList *only_rsc,
371+
bool check_parent);
372+
bool pe__native_is_filtered(const pcmk_resource_t *rsc, const GList *only_rsc,
373+
bool check_parent);
379374

380375
xmlNode *pe__failed_probe_for_rsc(const pcmk_resource_t *rsc, const char *name);
381376

lib/pacemaker/pcmk_sched_actions.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <crm_internal.h>
1111

12+
#include <stdbool.h> // bool, true, false
1213
#include <stdio.h>
1314
#include <sys/param.h>
1415
#include <glib.h>
@@ -734,7 +735,7 @@ handle_asymmetric_ordering(const pcmk_action_t *first, pcmk_action_t *then)
734735
if (pcmk_is_set(then->flags, pcmk__action_optional)) {
735736
enum rsc_role_e then_rsc_role;
736737

737-
then_rsc_role = then->rsc->priv->fns->state(then->rsc, TRUE);
738+
then_rsc_role = then->rsc->priv->fns->state(then->rsc, true);
738739

739740
if ((then_rsc_role == pcmk_role_stopped)
740741
&& pcmk__str_eq(then->task, PCMK_ACTION_STOP, pcmk__str_none)) {

lib/pacemaker/pcmk_sched_ordering.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2004-2024 the Pacemaker project contributors
2+
* Copyright 2004-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -10,7 +10,7 @@
1010
#include <crm_internal.h>
1111

1212
#include <inttypes.h> // PRIx32
13-
#include <stdbool.h>
13+
#include <stdbool.h> // bool, true, false
1414
#include <glib.h>
1515

1616
#include <crm/crm.h>
@@ -1312,7 +1312,7 @@ rsc_order_first(pcmk_resource_t *first_rsc, pcmk__action_relation_t *order)
13121312
parse_op_key(order->task1, NULL, &op_type, &interval_ms);
13131313
key = pcmk__op_key(first_rsc->id, op_type, interval_ms);
13141314

1315-
first_role = first_rsc->priv->fns->state(first_rsc, TRUE);
1315+
first_role = first_rsc->priv->fns->state(first_rsc, true);
13161316
if ((first_role == pcmk_role_stopped)
13171317
&& pcmk__str_eq(op_type, PCMK_ACTION_STOP, pcmk__str_none)) {
13181318
free(key);

lib/pacemaker/pcmk_sched_promotable.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2004-2024 the Pacemaker project contributors
2+
* Copyright 2004-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -9,6 +9,8 @@
99

1010
#include <crm_internal.h>
1111

12+
#include <stdbool.h> // bool, true, false
13+
1214
#include <crm/common/xml.h>
1315
#include <pacemaker-internal.h>
1416

@@ -190,7 +192,7 @@ node_to_be_promoted_on(const pcmk_resource_t *rsc)
190192
return NULL;
191193

192194
} else if (!pcmk_is_set(rsc->flags, pcmk__rsc_managed)) {
193-
if (rsc->priv->fns->state(rsc, TRUE) == pcmk_role_promoted) {
195+
if (rsc->priv->fns->state(rsc, true) == pcmk_role_promoted) {
194196
crm_notice("Unmanaged instance %s will be left promoted on %s",
195197
rsc->id, pcmk__node_name(node));
196198
} else {
@@ -284,8 +286,8 @@ cmp_promotable_instance(gconstpointer a, gconstpointer b)
284286
}
285287

286288
// If those are the same, prefer instance whose current role is higher
287-
role1 = rsc1->priv->fns->state(rsc1, TRUE);
288-
role2 = rsc2->priv->fns->state(rsc2, TRUE);
289+
role1 = rsc1->priv->fns->state(rsc1, true);
290+
role2 = rsc2->priv->fns->state(rsc2, true);
289291
if (role1 > role2) {
290292
pcmk__rsc_trace(rsc1,
291293
"%s has higher promotion priority than %s "
@@ -951,7 +953,7 @@ set_instance_priority(gpointer data, gpointer user_data)
951953
pcmk__rsc_trace(clone, "Assigning priority for %s: %s", instance->id,
952954
pcmk_role_text(instance->priv->next_role));
953955

954-
if (instance->priv->fns->state(instance, TRUE) == pcmk_role_started) {
956+
if (instance->priv->fns->state(instance, true) == pcmk_role_started) {
955957
set_current_role_unpromoted(instance, NULL);
956958
}
957959

@@ -967,7 +969,7 @@ set_instance_priority(gpointer data, gpointer user_data)
967969
return;
968970
}
969971

970-
next_role = instance->priv->fns->state(instance, FALSE);
972+
next_role = instance->priv->fns->state(instance, false);
971973
switch (next_role) {
972974
case pcmk_role_started:
973975
case pcmk_role_unknown:
@@ -1283,7 +1285,7 @@ pcmk__update_dependent_with_promotable(const pcmk_resource_t *primary,
12831285
continue;
12841286
}
12851287
if (instance->priv->fns->state(instance,
1286-
FALSE) == colocation->primary_role) {
1288+
false) == colocation->primary_role) {
12871289
update_dependent_allowed_nodes(dependent, primary, node,
12881290
colocation);
12891291
affected_nodes = g_list_prepend(affected_nodes, node);

0 commit comments

Comments
 (0)