pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
actions_internal.h
Go to the documentation of this file.
1/*
2 * Copyright 2004-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_ACTIONS_INTERNAL__H
11#define PCMK__CRM_COMMON_ACTIONS_INTERNAL__H
12
13#include <stdbool.h> // bool
14#include <stdint.h> // uint32_t, UINT32_C()
15#include <glib.h> // guint, GList, GHashTable
16#include <libxml/tree.h> // xmlNode
17
18#include <crm/common/actions.h> // PCMK_ACTION_MONITOR
19#include <crm/common/roles.h> // enum rsc_role_e
20#include <crm/common/scheduler_types.h> // pcmk_resource_t, pcmk_node_t
21#include <crm/common/strings_internal.h> // pcmk__str_eq()
22
23#include <crm/common/strings_internal.h> // pcmk__str_any_of()
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
30#define PCMK__OP_FMT "%s_%s_%u"
31
39#define pcmk__set_action_flags(action, flags_to_set) do { \
40 (action)->flags = pcmk__set_flags_as(__func__, __LINE__, \
41 LOG_TRACE, \
42 "Action", (action)->uuid, \
43 (action)->flags, \
44 (flags_to_set), \
45 #flags_to_set); \
46 } while (0)
47
55#define pcmk__clear_action_flags(action, flags_to_clear) do { \
56 (action)->flags = pcmk__clear_flags_as(__func__, __LINE__, \
57 LOG_TRACE, \
58 "Action", (action)->uuid, \
59 (action)->flags, \
60 (flags_to_clear), \
61 #flags_to_clear); \
62 } while (0)
63
72#define pcmk__set_raw_action_flags(action_flags, action_name, to_set) do { \
73 action_flags = pcmk__set_flags_as(__func__, __LINE__, \
74 LOG_TRACE, "Action", action_name, \
75 (action_flags), \
76 (to_set), #to_set); \
77 } while (0)
78
87#define pcmk__clear_raw_action_flags(action_flags, action_name, to_clear) \
88 do { \
89 action_flags = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE, \
90 "Action", action_name, \
91 (action_flags), \
92 (to_clear), #to_clear); \
93 } while (0)
94
95// Possible actions (including some pseudo-actions)
97 pcmk__action_unspecified = 0, // Unspecified or unknown action
99
100 // Each "completed" action must be the regular action plus 1
101
103 pcmk__action_stopped, // Stop completed
104
106 pcmk__action_started, // Start completed
107
109 pcmk__action_notified, // Notify completed
110
113
116
117 pcmk__action_shutdown, // Shut down node
118 pcmk__action_fence, // Fence node
119};
120
121// Action scheduling flags
123 // No action flags set (compare with equality rather than bit set)
125
126 // Whether action does not require invoking an agent
127 pcmk__action_pseudo = (UINT32_C(1) << 0),
128
129 // Whether action is runnable
130 pcmk__action_runnable = (UINT32_C(1) << 1),
131
132 // Whether action should not be executed
133 pcmk__action_optional = (UINT32_C(1) << 2),
134
135 // Whether action should be added to transition graph even if optional
136 pcmk__action_always_in_graph = (UINT32_C(1) << 3),
137
138 // Whether operation-specific instance attributes have been unpacked yet
139 pcmk__action_attrs_evaluated = (UINT32_C(1) << 4),
140
141 // Whether action is allowed to be part of a live migration
142 pcmk__action_migratable = (UINT32_C(1) << 7),
143
144 // Whether action has been added to transition graph
145 pcmk__action_added_to_graph = (UINT32_C(1) << 8),
146
147 // Whether action is a stop to abort a dangling migration
148 pcmk__action_migration_abort = (UINT32_C(1) << 11),
149
150 // Whether action is recurring monitor that must be rescheduled if active
151 pcmk__action_reschedule = (UINT32_C(1) << 13),
152
153 // Whether action has already been processed by a recursive procedure
154 pcmk__action_detect_loop = (UINT32_C(1) << 14),
155
156 // Whether action's inputs have been de-duplicated yet
157 pcmk__action_inputs_deduplicated = (UINT32_C(1) << 15),
158
159 // Whether action can be executed on DC rather than own node
160 pcmk__action_on_dc = (UINT32_C(1) << 16),
161};
162
163/* Possible responses to a resource action failure
164 *
165 * The order is significant; the values are in order of increasing severity so
166 * that they can be compared with less than and greater than.
167 */
169 pcmk__on_fail_ignore, // Act as if failure didn't happen
170 pcmk__on_fail_demote, // Demote if promotable, else stop
171 pcmk__on_fail_restart, // Restart resource
172
173 /* Fence the remote node created by the resource if fencing is enabled,
174 * otherwise attempt to restart the resource (used internally for some
175 * remote connection failures).
176 */
178
179 pcmk__on_fail_restart_container, // Restart resource's container
180 pcmk__on_fail_ban, // Ban resource from current node
181 pcmk__on_fail_block, // Treat resource as unmanaged
182 pcmk__on_fail_stop, // Stop resource and leave stopped
183 pcmk__on_fail_standby_node, // Put resource's node in standby
184 pcmk__on_fail_fence_node, // Fence resource's node
185};
186
187// What resource needs before it can be recovered from a failed node
189 pcmk__requires_nothing = 0, // Resource can be recovered immediately
190 pcmk__requires_quorum = 1, // Resource can be recovered if quorate
191 pcmk__requires_fencing = 2, // Resource can be recovered after fencing
192};
193
194// Implementation of pcmk_action_t
196 int id; // Counter to identify action
197
198 /*
199 * When the controller aborts a transition graph, it sets an abort priority.
200 * If this priority is higher, the action will still be executed anyway.
201 * Pseudo-actions are always allowed, so this is irrelevant for them.
202 */
204
205 pcmk_resource_t *rsc; // Resource to apply action to, if any
206 pcmk_node_t *node; // Copy of node to execute action on, if any
207 xmlNode *op_entry; // Action XML configuration, if any
208 char *task; // Action name
209 char *uuid; // Action key
210 char *cancel_task; // If task is "cancel", the action being cancelled
211 char *reason; // Readable description of why action is needed
212 uint32_t flags; // Group of enum pcmk__action_flags
213 enum pcmk__requires needs; // Prerequisite for recovery
214 enum pcmk__on_fail on_fail; // Response to failure
215 enum rsc_role_e fail_role; // Resource role if action fails
216 GHashTable *meta; // Meta-attributes relevant to action
217 GHashTable *extra; // Action-specific instance attributes
218 pcmk_scheduler_t *scheduler; // Scheduler data this action is part of
219
220 /* Current count of runnable instance actions for "first" action in an
221 * ordering dependency with pcmk__ar_min_runnable set.
222 */
224
225 /*
226 * Number of instance actions for "first" action in an ordering dependency
227 * with pcmk__ar_min_runnable set that must be runnable before this action
228 * can be runnable.
229 */
231
232 // Actions in a relation with this one (as pcmk__related_action_t *)
235};
236
237void pcmk__free_action(gpointer user_data);
238char *pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms);
239char *pcmk__notify_key(const char *rsc_id, const char *notify_type,
240 const char *op_type);
241char *pcmk__transition_key(int transition_id, int action_id, int target_rc,
242 const char *node);
243void pcmk__filter_op_for_digest(xmlNode *param_set);
244bool pcmk__is_fencing_action(const char *action);
245enum pcmk__action_type pcmk__parse_action(const char *action_name);
247const char *pcmk__on_fail_text(enum pcmk__on_fail on_fail);
248
249
259static inline const char *
260pcmk__readable_action(const char *action_name, guint interval_ms) {
261 if ((interval_ms == 0)
262 && pcmk__str_eq(action_name, PCMK_ACTION_MONITOR, pcmk__str_none)) {
263 return "probe";
264 }
265 return action_name;
266}
267
276static inline bool
277pcmk__is_up_action(const char *action)
278{
281}
282
291static inline bool
292pcmk__is_down_action(const char *action)
293{
296}
297
298#ifdef __cplusplus
299}
300#endif
301
302#endif // PCMK__CRM_COMMON_ACTIONS_INTERNAL__H
APIs related to actions.
#define PCMK_ACTION_STOP
Definition actions.h:66
#define PCMK_ACTION_PROMOTE
Definition actions.h:57
#define PCMK_ACTION_START
Definition actions.h:63
#define PCMK_ACTION_MIGRATE_FROM
Definition actions.h:49
#define PCMK_ACTION_MIGRATE_TO
Definition actions.h:50
#define PCMK_ACTION_MONITOR
Definition actions.h:51
#define PCMK_ACTION_DEMOTE
Definition actions.h:40
void pcmk__free_action(gpointer user_data)
Definition actions.c:189
void pcmk__filter_op_for_digest(xmlNode *param_set)
Definition digest.c:299
pcmk__action_flags
@ pcmk__action_inputs_deduplicated
@ pcmk__no_action_flags
@ pcmk__action_always_in_graph
@ pcmk__action_migration_abort
@ pcmk__action_runnable
@ pcmk__action_added_to_graph
@ pcmk__action_migratable
@ pcmk__action_detect_loop
@ pcmk__action_reschedule
@ pcmk__action_optional
@ pcmk__action_attrs_evaluated
@ pcmk__action_on_dc
@ pcmk__action_pseudo
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
Definition actions.c:365
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
Definition actions.c:225
bool pcmk__is_fencing_action(const char *action)
Definition actions.c:611
const char * pcmk__action_text(enum pcmk__action_type action)
Definition actions.c:34
pcmk__on_fail
@ pcmk__on_fail_stop
@ pcmk__on_fail_reset_remote
@ pcmk__on_fail_restart_container
@ pcmk__on_fail_ban
@ pcmk__on_fail_fence_node
@ pcmk__on_fail_block
@ pcmk__on_fail_restart
@ pcmk__on_fail_ignore
@ pcmk__on_fail_demote
@ pcmk__on_fail_standby_node
pcmk__requires
@ pcmk__requires_nothing
@ pcmk__requires_fencing
@ pcmk__requires_quorum
enum pcmk__action_type pcmk__parse_action(const char *action_name)
Definition actions.c:90
char * pcmk__transition_key(int transition_id, int action_id, int target_rc, const char *node)
Definition actions.c:432
const char * pcmk__on_fail_text(enum pcmk__on_fail on_fail)
Definition actions.c:146
pcmk__action_type
@ pcmk__action_stop
@ pcmk__action_started
@ pcmk__action_monitor
@ pcmk__action_fence
@ pcmk__action_stopped
@ pcmk__action_notify
@ pcmk__action_start
@ pcmk__action_demote
@ pcmk__action_promote
@ pcmk__action_shutdown
@ pcmk__action_notified
@ pcmk__action_unspecified
@ pcmk__action_promoted
@ pcmk__action_demoted
const char * action
Definition pcmk_fence.c:32
Scheduler API for resource roles.
rsc_role_e
Definition roles.h:34
Type aliases needed to define scheduler objects.
@ pcmk__str_none
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition strings.c:1053
pcmk_node_t * node
pcmk_scheduler_t * scheduler
pcmk_resource_t * rsc
enum pcmk__requires needs
enum rsc_role_e fail_role
GHashTable * meta
enum pcmk__on_fail on_fail
GHashTable * extra