pacemaker 2.1.8-2.1.8
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
actions.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__H
11#define PCMK__CRM_COMMON_ACTIONS__H
12
13#include <stdbool.h> // bool
14#include <strings.h> // strcasecmp()
15#include <glib.h> // gboolean, guint
16#include <libxml/tree.h> // xmlNode
17
18#include <crm/lrmd_events.h> // lrmd_event_data_t
19
20#include <glib.h> // GList, GHashTable
21#include <libxml/tree.h> // xmlNode
22
23#include <crm/common/nodes.h>
24#include <crm/common/resources.h> // enum rsc_start_requirement, etc.
25#include <crm/common/scheduler_types.h> // pcmk_resource_t, pcmk_node_t
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
38#define PCMK_DEFAULT_ACTION_TIMEOUT_MS 20000
39
40// @COMPAT We don't need a separate timeout for metadata, much less a longer one
42#define PCMK_DEFAULT_METADATA_TIMEOUT_MS 30000
43
44// Action names as strings
45#define PCMK_ACTION_CANCEL "cancel"
46#define PCMK_ACTION_CLEAR_FAILCOUNT "clear_failcount"
47#define PCMK_ACTION_CLONE_ONE_OR_MORE "clone-one-or-more"
48#define PCMK_ACTION_DELETE "delete"
49#define PCMK_ACTION_DEMOTE "demote"
50#define PCMK_ACTION_DEMOTED "demoted"
51#define PCMK_ACTION_DO_SHUTDOWN "do_shutdown"
52#define PCMK_ACTION_LIST "list"
53#define PCMK_ACTION_LRM_DELETE "lrm_delete"
54#define PCMK_ACTION_LOAD_STOPPED "load_stopped"
55#define PCMK_ACTION_MAINTENANCE_NODES "maintenance_nodes"
56#define PCMK_ACTION_META_DATA "meta-data"
57#define PCMK_ACTION_METADATA "metadata"
58#define PCMK_ACTION_MIGRATE_FROM "migrate_from"
59#define PCMK_ACTION_MIGRATE_TO "migrate_to"
60#define PCMK_ACTION_MONITOR "monitor"
61#define PCMK_ACTION_NOTIFIED "notified"
62#define PCMK_ACTION_NOTIFY "notify"
63#define PCMK_ACTION_OFF "off"
64#define PCMK_ACTION_ON "on"
65#define PCMK_ACTION_ONE_OR_MORE "one-or-more"
66#define PCMK_ACTION_PROMOTE "promote"
67#define PCMK_ACTION_PROMOTED "promoted"
68#define PCMK_ACTION_REBOOT "reboot"
69#define PCMK_ACTION_RELOAD "reload"
70#define PCMK_ACTION_RELOAD_AGENT "reload-agent"
71#define PCMK_ACTION_RUNNING "running"
72#define PCMK_ACTION_START "start"
73#define PCMK_ACTION_STATUS "status"
74#define PCMK_ACTION_STONITH "stonith"
75#define PCMK_ACTION_STOP "stop"
76#define PCMK_ACTION_STOPPED "stopped"
77#define PCMK_ACTION_VALIDATE_ALL "validate-all"
78
79// Possible actions (including some pseudo-actions)
80// @COMPAT Make this internal when we can break API backward compatibility
125
126// Possible responses to a resource action failure
127// @COMPAT Make this internal when we can break API backward compatibility
131 /* The order is (partially) significant here; the values from
132 * pcmk_on_fail_ignore through pcmk_on_fail_fence_node are in order of
133 * increasing severity.
134 *
135 * @COMPAT The values should be ordered and numbered per the "TODO" comments
136 * below, so all values are in order of severity and there is room for
137 * future additions, but that would break API compatibility.
138 * @TODO For now, we just use a function to compare the values specially, but
139 * at the next compatibility break, we should arrange things
140 * properly so we can compare with less than and greater than.
141 */
142
143 // @TODO Define as 10
144 pcmk_on_fail_ignore = 0, // Act as if failure didn't happen
145
146 // @TODO Define as 30
147 pcmk_on_fail_restart = 1, // Restart resource
148
149 // @TODO Define as 60
150 pcmk_on_fail_ban = 2, // Ban resource from current node
151
152 // @TODO Define as 70
153 pcmk_on_fail_block = 3, // Treat resource as unmanaged
154
155 // @TODO Define as 80
156 pcmk_on_fail_stop = 4, // Stop resource and leave stopped
157
158 // @TODO Define as 90
159 pcmk_on_fail_standby_node = 5, // Put resource's node in standby
160
161 // @TODO Define as 100
162 pcmk_on_fail_fence_node = 6, // Fence resource's node
163
164 // @COMPAT Values below here are out of desired order for API compatibility
165
166 // @TODO Define as 50
167 pcmk_on_fail_restart_container = 7, // Restart resource's container
168
169 // @TODO Define as 40
170 /*
171 * Fence the remote node created by the resource if fencing is enabled,
172 * otherwise attempt to restart the resource (used internally for some
173 * remote connection failures).
174 */
176
177 // @TODO Define as 20
178 pcmk_on_fail_demote = 9, // Demote if promotable, else stop
179
180#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
191#endif
192};
194
195// Action scheduling flags
196// @COMPAT Make this internal when we can break API backward compatibility
200 // No action flags set (compare with equality rather than bit set)
202
203 // Whether action does not require invoking an agent
205
206 // Whether action is runnable
208
209 // Whether action should not be executed
211
212 // Whether action should be added to transition graph even if optional
214
215 // Whether operation-specific instance attributes have been unpacked yet
217
218 // Whether action is allowed to be part of a live migration
220
221 // Whether action has been added to transition graph
223
224 // Whether action is a stop to abort a dangling migration
226
227 /*
228 * Whether action is an ordering point for minimum required instances
229 * (used to implement ordering after clones with \c PCMK_META_CLONE_MIN
230 * configured, and ordered sets with \c PCMK_XA_REQUIRE_ALL set to
231 * \c PCMK_VALUE_FALSE).
232 */
234
235 // Whether action is recurring monitor that must be rescheduled if active
237
238 // Whether action has already been processed by a recursive procedure
240
241 // Whether action's inputs have been de-duplicated yet
243
244 // Whether action can be executed on DC rather than own node
245 pcmk_action_on_dc = (1 << 16),
246
247#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
257 pe_action_clear = (1 << 10),
264#endif
265};
267
268/* @COMPAT enum pe_link_state and enum pe_ordering are currently needed for
269 * struct pe_action_wrapper_s (which is public) but should be removed at an
270 * API compatibility break when that can be refactored and made internal
271 */
272
278#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
280#endif
281};
282
312
313// Action sequenced relative to another action
314// @COMPAT This should be internal
316 // @COMPAT This should be uint32_t
317 enum pe_ordering type; // Group of enum pcmk__action_relation_flags
318
319 // @COMPAT This should be a bool
320 enum pe_link_state state; // Whether action has been added to graph yet
321
322 pcmk_action_t *action; // Action to be sequenced
323};
325
326// Implementation of pcmk_action_t
327// @COMPAT Make this internal when we can break API backward compatibility
331 int id; // Counter to identify action
332
333 /*
334 * When the controller aborts a transition graph, it sets an abort priority.
335 * If this priority is higher, the action will still be executed anyway.
336 * Pseudo-actions are always allowed, so this is irrelevant for them.
337 */
339
340 pcmk_resource_t *rsc; // Resource to apply action to, if any
341 pcmk_node_t *node; // Node to execute action on, if any
342 xmlNode *op_entry; // Action XML configuration, if any
343 char *task; // Action name
344 char *uuid; // Action key
345 char *cancel_task; // If task is "cancel", the action being cancelled
346 char *reason; // Readable description of why action is needed
347
348 //@ COMPAT Change to uint32_t at a compatibility break
349 enum pe_action_flags flags; // Group of enum pe_action_flags
350
351 enum rsc_start_requirement needs; // Prerequisite for recovery
352 enum action_fail_response on_fail; // Response to failure
353 enum rsc_role_e fail_role; // Resource role if action fails
354 GHashTable *meta; // Meta-attributes relevant to action
355 GHashTable *extra; // Action-specific instance attributes
356
357 /* Current count of runnable instance actions for "first" action in an
358 * ordering dependency with pcmk__ar_min_runnable set.
359 */
360 int runnable_before; // For Pacemaker use only
361
362 /*
363 * Number of instance actions for "first" action in an ordering dependency
364 * with pcmk__ar_min_runnable set that must be runnable before this action
365 * can be runnable.
366 */
368
369 // Actions in a relation with this one (as pcmk__related_action_t *)
372
373 /* This is intended to hold data that varies by the type of action, but is
374 * not currently used. Some of the above fields could be moved here except
375 * for API backward compatibility.
376 */
378};
380
381// @COMPAT Make this internal when we can break API backward compatibility
383const char *pcmk_action_text(enum action_tasks action);
384
385// @COMPAT Make this internal when we can break API backward compatibility
387enum action_tasks pcmk_parse_action(const char *action_name);
388
389// @COMPAT Make this internal when we can break API backward compatibility
391const char *pcmk_on_fail_text(enum action_fail_response on_fail);
392
393// For parsing various action-related string specifications
394gboolean parse_op_key(const char *key, char **rsc_id, char **op_type,
395 guint *interval_ms);
396gboolean decode_transition_key(const char *key, char **uuid, int *transition_id,
397 int *action_id, int *target_rc);
398gboolean decode_transition_magic(const char *magic, char **uuid,
399 int *transition_id, int *action_id,
400 int *op_status, int *op_rc, int *target_rc);
401
402// @COMPAT Either these shouldn't be in libcrmcommon or lrmd_event_data_t should
403int rsc_op_expected_rc(const lrmd_event_data_t *event);
404gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc);
405
406bool crm_op_needs_metadata(const char *rsc_class, const char *op);
407
408xmlNode *crm_create_op_xml(xmlNode *parent, const char *prefix,
409 const char *task, const char *interval_spec,
410 const char *timeout);
411
412bool pcmk_is_probe(const char *task, guint interval);
413bool pcmk_xe_is_probe(const xmlNode *xml_op);
414bool pcmk_xe_mask_probe_failure(const xmlNode *xml_op);
415
416#ifdef __cplusplus
417}
418#endif
419
420#endif // PCMK__CRM_COMMON_ACTIONS__H
bool pcmk_xe_mask_probe_failure(const xmlNode *xml_op)
Check whether an action history entry represents a maskable probe.
Definition probes.c:69
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
Definition actions.c:250
gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc)
Definition actions.c:484
const char * pcmk_on_fail_text(enum action_fail_response on_fail)
Get string equivalent of a failure handling type.
Definition actions.c:147
bool pcmk_is_probe(const char *task, guint interval)
Check whether an action name and interval represent a probe.
Definition probes.c:30
gboolean decode_transition_key(const char *key, char **uuid, int *transition_id, int *action_id, int *target_rc)
Parse a transition key into its constituent parts.
Definition actions.c:426
pe_ordering
Definition actions.h:283
@ pe_order_implies_first_printed
Definition actions.h:300
@ pe_order_implies_first_master
Definition actions.h:309
@ pe_order_trace
Definition actions.h:308
@ pe_order_pseudo_left
Definition actions.h:293
@ pe_order_restart
Definition actions.h:296
@ pe_order_anti_colocation
Definition actions.h:305
@ pe_order_implies_then
Definition actions.h:289
@ pe_order_same_node
Definition actions.h:299
@ pe_order_one_or_more
Definition actions.h:304
@ pe_order_none
Definition actions.h:284
@ pe_order_then_cancels_first
Definition actions.h:307
@ pe_order_serialize_only
Definition actions.h:298
@ pe_order_implies_then_on_node
Definition actions.h:294
@ pe_order_stonith_stop
Definition actions.h:297
@ pe_order_asymmetrical
Definition actions.h:302
@ pe_order_implies_first_migratable
Definition actions.h:291
@ pe_order_preserve
Definition actions.h:306
@ pe_order_implies_then_printed
Definition actions.h:301
@ pe_order_optional
Definition actions.h:286
@ pe_order_implies_first
Definition actions.h:288
@ pe_order_runnable_left
Definition actions.h:292
@ pe_order_probe
Definition actions.h:295
@ pe_order_promoted_implies_first
Definition actions.h:290
@ pe_order_load
Definition actions.h:303
@ pe_order_apply_first_non_migratable
Definition actions.h:287
pe_link_state
Definition actions.h:275
@ pe_link_not_dumped
Definition actions.h:276
@ pe_link_dumped
Definition actions.h:277
@ pe_link_dup
Definition actions.h:279
action_fail_response
Definition actions.h:130
@ action_fail_block
Definition actions.h:184
@ pcmk_on_fail_ban
Definition actions.h:150
@ pcmk_on_fail_fence_node
Definition actions.h:162
@ pcmk_on_fail_ignore
Definition actions.h:144
@ action_fail_reset_remote
Definition actions.h:189
@ pcmk_on_fail_restart_container
Definition actions.h:167
@ action_fail_migrate
Definition actions.h:183
@ pcmk_on_fail_demote
Definition actions.h:178
@ pcmk_on_fail_standby_node
Definition actions.h:159
@ action_fail_ignore
Definition actions.h:181
@ pcmk_on_fail_block
Definition actions.h:153
@ action_fail_restart_container
Definition actions.h:188
@ action_fail_fence
Definition actions.h:187
@ pcmk_on_fail_reset_remote
Definition actions.h:175
@ pcmk_on_fail_stop
Definition actions.h:156
@ pcmk_on_fail_restart
Definition actions.h:147
@ action_fail_standby
Definition actions.h:186
@ action_fail_demote
Definition actions.h:190
@ action_fail_stop
Definition actions.h:185
@ action_fail_recover
Definition actions.h:182
xmlNode * crm_create_op_xml(xmlNode *parent, const char *prefix, const char *task, const char *interval_spec, const char *timeout)
Create a CIB XML element for an operation.
Definition actions.c:521
pe_action_flags
Definition actions.h:199
@ pe_action_optional
Definition actions.h:250
@ pe_action_clear
Definition actions.h:257
@ pe_action_tracking
Definition actions.h:261
@ pcmk_action_detect_loop
Definition actions.h:239
@ pe_action_processed
Definition actions.h:256
@ pcmk_action_runnable
Definition actions.h:207
@ pcmk_action_reschedule
Definition actions.h:236
@ pe_action_runnable
Definition actions.h:249
@ pcmk_action_migratable
Definition actions.h:219
@ pcmk_action_added_to_graph
Definition actions.h:222
@ pcmk_action_pseudo
Definition actions.h:204
@ pe_action_implied_by_stonith
Definition actions.h:253
@ pcmk_action_attrs_evaluated
Definition actions.h:216
@ pe_action_dumped
Definition actions.h:255
@ pe_action_dedup
Definition actions.h:262
@ pe_action_dangle
Definition actions.h:258
@ pcmk_action_optional
Definition actions.h:210
@ pcmk_action_migration_abort
Definition actions.h:225
@ pe_action_pseudo
Definition actions.h:248
@ pcmk_action_on_dc
Definition actions.h:245
@ pe_action_have_node_attrs
Definition actions.h:252
@ pcmk_action_min_runnable
Definition actions.h:233
@ pcmk_no_action_flags
Definition actions.h:201
@ pcmk_action_always_in_graph
Definition actions.h:213
@ pe_action_print_always
Definition actions.h:251
@ pcmk_action_inputs_deduplicated
Definition actions.h:242
@ pe_action_reschedule
Definition actions.h:260
@ pe_action_requires_any
Definition actions.h:259
@ pe_action_dc
Definition actions.h:263
@ pe_action_migrate_runnable
Definition actions.h:254
action_tasks
Definition actions.h:83
@ pcmk_action_start
Definition actions.h:92
@ pcmk_action_fence
Definition actions.h:105
@ pcmk_action_demote
Definition actions.h:101
@ no_action
Definition actions.h:108
@ pcmk_action_stopped
Definition actions.h:90
@ pcmk_action_promote
Definition actions.h:98
@ started_rsc
Definition actions.h:113
@ pcmk_action_started
Definition actions.h:93
@ pcmk_action_notified
Definition actions.h:96
@ shutdown_crm
Definition actions.h:120
@ start_rsc
Definition actions.h:112
@ action_demote
Definition actions.h:118
@ stonith_node
Definition actions.h:121
@ action_demoted
Definition actions.h:119
@ action_notified
Definition actions.h:115
@ stop_rsc
Definition actions.h:110
@ pcmk_action_demoted
Definition actions.h:102
@ pcmk_action_stop
Definition actions.h:89
@ action_promote
Definition actions.h:116
@ pcmk_action_shutdown
Definition actions.h:104
@ monitor_rsc
Definition actions.h:109
@ pcmk_action_unspecified
Definition actions.h:84
@ action_promoted
Definition actions.h:117
@ pcmk_action_promoted
Definition actions.h:99
@ pcmk_action_notify
Definition actions.h:95
@ pcmk_action_monitor
Definition actions.h:85
@ stopped_rsc
Definition actions.h:111
@ action_notify
Definition actions.h:114
const char * pcmk_action_text(enum action_tasks action)
Get string equivalent of an action type.
Definition actions.c:37
enum action_tasks pcmk_parse_action(const char *action_name)
Parse an action type from an action name.
Definition actions.c:92
int rsc_op_expected_rc(const lrmd_event_data_t *event)
Definition actions.c:473
bool crm_op_needs_metadata(const char *rsc_class, const char *op)
Check whether an operation requires resource agent meta-data.
Definition actions.c:548
gboolean decode_transition_magic(const char *magic, char **uuid, int *transition_id, int *action_id, int *op_status, int *op_rc, int *target_rc)
Parse a transition magic string into its constituent parts.
Definition actions.c:363
bool pcmk_xe_is_probe(const xmlNode *xml_op)
Check whether an action history entry represents a probe.
Definition probes.c:45
const char * parent
Definition cib.c:27
#define PCMK_ALLOW_DEPRECATED
Allow use of deprecated Pacemaker APIs.
Definition crm.h:46
Resource agent executor events.
Scheduler API for nodes.
unsigned int timeout
Definition pcmk_fence.c:32
const char * action
Definition pcmk_fence.c:30
Scheduler API for resources.
rsc_start_requirement
Definition resources.h:52
rsc_role_e
Definition roles.h:34
Type aliases needed to define scheduler objects.
op_status
pcmk_node_t * node
Definition actions.h:341
char * reason
Definition actions.h:346
int runnable_before
Definition actions.h:360
char * uuid
Definition actions.h:344
char * task
Definition actions.h:343
int priority
Definition actions.h:338
void * action_details
Definition actions.h:377
enum rsc_role_e fail_role
Definition actions.h:353
enum rsc_start_requirement needs
Definition actions.h:351
GList * actions_after
Definition actions.h:371
GHashTable * meta
Definition actions.h:354
enum action_fail_response on_fail
Definition actions.h:352
char * cancel_task
Definition actions.h:345
enum pe_action_flags flags
Definition actions.h:349
int required_runnable_before
Definition actions.h:367
xmlNode * op_entry
Definition actions.h:342
pcmk_resource_t * rsc
Definition actions.h:340
GHashTable * extra
Definition actions.h:355
GList * actions_before
Definition actions.h:370
enum pe_ordering type
Definition actions.h:317
pcmk_action_t * action
Definition actions.h:322
enum pe_link_state state
Definition actions.h:320