pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
nodes_internal.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 the Pacemaker project contributors
3 *
4 * The version control history for this file may have further details.
5 *
6 * This source code is licensed under the GNU Lesser General Public License
7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8 */
9
10#ifndef PCMK__CRM_COMMON_NODES_INTERNAL__H
11#define PCMK__CRM_COMMON_NODES_INTERNAL__H
12
13#include <stdio.h> // NULL
14#include <stdbool.h> // bool
15#include <stdint.h> // uint32_t, UINT32_C()
16
17#include <glib.h> // gpointer, GList, GHashTable
18#include <crm/common/nodes.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/*
25 * Special node attributes
26 */
27
28#define PCMK__NODE_ATTR_SHUTDOWN "shutdown"
29
30/* @COMPAT Deprecated since 2.1.8. Use a location constraint with
31 * PCMK_XA_RSC_PATTERN=".*" and PCMK_XA_RESOURCE_DISCOVERY="never" instead of
32 * PCMK__NODE_ATTR_RESOURCE_DISCOVERY_ENABLED="false".
33 */
34#define PCMK__NODE_ATTR_RESOURCE_DISCOVERY_ENABLED "resource-discovery-enabled"
35
36enum pcmk__node_variant { // Possible node types
37 pcmk__node_variant_cluster = 1, // Cluster layer node
38 pcmk__node_variant_remote = 2, // Pacemaker Remote node
39};
40
42 pcmk__node_none = UINT32_C(0),
43
44 // Whether node is in standby mode
45 pcmk__node_standby = (UINT32_C(1) << 0),
46
47 // Whether node is in standby mode due to PCMK_META_ON_FAIL
48 pcmk__node_fail_standby = (UINT32_C(1) << 1),
49
50 // Whether node has ever joined cluster (and thus has node state in CIB)
51 pcmk__node_seen = (UINT32_C(1) << 2),
52
53 // Whether expected join state is member
54 pcmk__node_expected_up = (UINT32_C(1) << 3),
55
56 // Whether probes are allowed on node
57 pcmk__node_probes_allowed = (UINT32_C(1) << 4),
58
59 /* Whether this either is a guest node whose guest resource must be
60 * recovered or a remote node that must be fenced
61 */
62 pcmk__node_remote_reset = (UINT32_C(1) << 5),
63
64 /* Whether this is a Pacemaker Remote node that was fenced since it was last
65 * connected by the cluster
66 */
67 pcmk__node_remote_fenced = (UINT32_C(1) << 6),
68
69 /*
70 * Whether this is a Pacemaker Remote node previously marked in its
71 * node state as being in maintenance mode
72 */
73 pcmk__node_remote_maint = (UINT32_C(1) << 7),
74
75 // Whether node history has been unpacked
76 pcmk__node_unpacked = (UINT32_C(1) << 8),
77};
78
79// When to probe a resource on a node (as specified in location constraints)
81 pcmk__probe_always = 0, // Always probe resource on node
82 pcmk__probe_never = 1, // Never probe resource on node
83 pcmk__probe_exclusive = 2, // Probe only on designated nodes
84};
85
86/* Per-node data used in resource assignment
87 *
88 * @COMPAT When we can make the pcmk_node_t implementation internal, move these
89 * there and drop this struct.
90 */
92 int score; // Node's score for relevant resource
93 int count; // Counter reused by assignment and promotion code
94 enum pcmk__probe_mode probe_mode; // When to probe resource on this node
95};
96
97/* Implementation of pcmk__node_private_t (pcmk_node_t objects are shallow
98 * copies, so all pcmk_node_t objects for the same node will share the same
99 * private data)
100 */
102 /* Node's XML ID in the CIB (the cluster layer ID for cluster nodes,
103 * the node name for Pacemaker Remote nodes)
104 */
105 const char *id;
106
107 /*
108 * Sum of priorities of all resources active on node and on any guest nodes
109 * connected to this node, with +1 for promoted instances (used to compare
110 * nodes for PCMK_OPT_PRIORITY_FENCING_DELAY)
111 */
113
114 const char *name; // Node name in cluster
115 enum pcmk__node_variant variant; // Node variant
116 uint32_t flags; // Group of enum pcmk__node_flags
117 GHashTable *attrs; // Node attributes
118 GHashTable *utilization; // Node utilization attributes
119 int num_resources; // Number of active resources on node
120 GList *assigned_resources; // List of resources assigned to node
121 GHashTable *digest_cache; // Cache of calculated resource digests
122 pcmk_resource_t *remote; // Pacemaker Remote connection (if any)
123 pcmk_scheduler_t *scheduler; // Scheduler data that node is part of
124};
125
126void pcmk__free_node_copy(void *data);
127pcmk_node_t *pcmk__find_node_in_list(const GList *nodes, const char *node_name);
128
136#define pcmk__set_node_flags(node, flags_to_set) do { \
137 (node)->priv->flags = pcmk__set_flags_as(__func__, __LINE__, \
138 LOG_TRACE, "Node", pcmk__node_name(node), \
139 (node)->priv->flags, (flags_to_set), #flags_to_set); \
140 } while (0)
141
149#define pcmk__clear_node_flags(node, flags_to_clear) do { \
150 (node)->priv->flags = pcmk__clear_flags_as(__func__, __LINE__, \
151 LOG_TRACE, "Node", pcmk__node_name(node), \
152 (node)->priv->flags, (flags_to_clear), #flags_to_clear); \
153 } while (0)
154
155void pcmk__free_node(gpointer user_data);
156
167static inline const char *
168pcmk__node_name(const pcmk_node_t *node)
169{
170 if (node == NULL) {
171 return "unspecified node";
172
173 } else if (node->priv->name != NULL) {
174 return node->priv->name;
175
176 } else if (node->priv->id != NULL) {
177 return node->priv->id;
178
179 } else {
180 return "unidentified node";
181 }
182}
183
193static inline bool
194pcmk__same_node(const pcmk_node_t *node1, const pcmk_node_t *node2)
195{
196 return (node1 != NULL) && (node2 != NULL)
197 && (node1->priv == node2->priv);
198}
199
200#ifdef __cplusplus
201}
202#endif
203
204#endif // PCMK__CRM_COMMON_NODES_INTERNAL__H
char data[0]
Definition cpg.c:10
Scheduler API for nodes.
pcmk_node_t * pcmk__find_node_in_list(const GList *nodes, const char *node_name)
Definition nodes.c:198
void pcmk__free_node(gpointer user_data)
Definition nodes.c:22
pcmk__node_flags
@ pcmk__node_none
@ pcmk__node_remote_fenced
@ pcmk__node_remote_maint
@ pcmk__node_fail_standby
@ pcmk__node_remote_reset
@ pcmk__node_unpacked
@ pcmk__node_standby
@ pcmk__node_expected_up
@ pcmk__node_seen
@ pcmk__node_probes_allowed
pcmk__node_variant
@ pcmk__node_variant_remote
@ pcmk__node_variant_cluster
void pcmk__free_node_copy(void *data)
Definition nodes.c:64
pcmk__probe_mode
@ pcmk__probe_always
@ pcmk__probe_exclusive
@ pcmk__probe_never
pcmk_node_t node2
pcmk_node_t node1
enum pcmk__probe_mode probe_mode
enum pcmk__node_variant variant
GHashTable * digest_cache
GHashTable * utilization
pcmk_resource_t * remote
pcmk_scheduler_t * scheduler
pcmk__node_private_t * priv
Definition nodes.h:85