pacemaker 2.1.7-2.1.7
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
actions.h
Go to the documentation of this file.
1/*
2 * Copyright 2004-2023 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_MIGRATE_FROM "migrate_from"
58#define PCMK_ACTION_MIGRATE_TO "migrate_to"
59#define PCMK_ACTION_MONITOR "monitor"
60#define PCMK_ACTION_NOTIFIED "notified"
61#define PCMK_ACTION_NOTIFY "notify"
62#define PCMK_ACTION_OFF "off"
63#define PCMK_ACTION_ON "on"
64#define PCMK_ACTION_ONE_OR_MORE "one-or-more"
65#define PCMK_ACTION_PROMOTE "promote"
66#define PCMK_ACTION_PROMOTED "promoted"
67#define PCMK_ACTION_REBOOT "reboot"
68#define PCMK_ACTION_RELOAD "reload"
69#define PCMK_ACTION_RELOAD_AGENT "reload-agent"
70#define PCMK_ACTION_RUNNING "running"
71#define PCMK_ACTION_START "start"
72#define PCMK_ACTION_STATUS "status"
73#define PCMK_ACTION_STONITH "stonith"
74#define PCMK_ACTION_STOP "stop"
75#define PCMK_ACTION_STOPPED "stopped"
76#define PCMK_ACTION_VALIDATE_ALL "validate-all"
77
147
150 /* The order is (partially) significant here; the values from
151 * pcmk_on_fail_ignore through pcmk_on_fail_fence_node are in order of
152 * increasing severity.
153 *
154 * @COMPAT The values should be ordered and numbered per the "TODO" comments
155 * below, so all values are in order of severity and there is room for
156 * future additions, but that would break API compatibility.
157 * @TODO For now, we just use a function to compare the values specially, but
158 * at the next compatibility break, we should arrange things
159 * properly so we can compare with less than and greater than.
160 */
161
162 // @TODO Define as 10
164
165 // @TODO Define as 30
167
168 // @TODO Define as 60
170
171 // @TODO Define as 70
173
174 // @TODO Define as 80
176
177 // @TODO Define as 90
179
180 // @TODO Define as 100
182
183 // @COMPAT Values below here are out of desired order for API compatibility
184
185 // @TODO Define as 50
187
188 // @TODO Define as 40
195
196 // @TODO Define as 20
198
199#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
202
205
208
211
214
217
220
223
226
229#endif
230};
231
236
239
242
245
248
251
254
257
260
267
270
273
276
278 pcmk_action_on_dc = (1 << 16),
279
280#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
283
286
289
292
295
298
301
304
307
309 pe_action_clear = (1 << 10),
310
313
316
319
322
325
328#endif
329};
330
331/* @COMPAT enum pe_link_state and enum pe_ordering are currently needed for
332 * struct pe_action_wrapper_s (which is public) but should be removed at an
333 * API compatibility break when that can be refactored and made internal
334 */
335
341#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
343#endif
344};
345
375
376// Action sequenced relative to another action
377// @COMPAT This should be internal
379 // @COMPAT This should be uint32_t
380 enum pe_ordering type; // Group of enum pcmk__action_relation_flags
381
382 // @COMPAT This should be a bool
383 enum pe_link_state state; // Whether action has been added to graph yet
384
385 pcmk_action_t *action; // Action to be sequenced
386};
388
391 int id;
392
399
402 xmlNode *op_entry;
403 char *task;
404 char *uuid;
406 char *reason;
407
408 //@ COMPAT Change to uint32_t at a compatibility break
410
414 GHashTable *meta;
415 GHashTable *extra;
416
417 /* Current count of runnable instance actions for "first" action in an
418 * ordering dependency with pcmk__ar_min_runnable set.
419 */
421
428
429 // Actions in a relation with this one (as pcmk__related_action_t *)
432
433 /* This is intended to hold data that varies by the type of action, but is
434 * not currently used. Some of the above fields could be moved here except
435 * for API backward compatibility.
436 */
438};
439
440// For parsing various action-related string specifications
441gboolean parse_op_key(const char *key, char **rsc_id, char **op_type,
442 guint *interval_ms);
443gboolean decode_transition_key(const char *key, char **uuid, int *transition_id,
444 int *action_id, int *target_rc);
445gboolean decode_transition_magic(const char *magic, char **uuid,
446 int *transition_id, int *action_id,
447 int *op_status, int *op_rc, int *target_rc);
448
449// @COMPAT Either these shouldn't be in libcrmcommon or lrmd_event_data_t should
450int rsc_op_expected_rc(const lrmd_event_data_t *event);
451gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc);
452
453bool crm_op_needs_metadata(const char *rsc_class, const char *op);
454
455xmlNode *crm_create_op_xml(xmlNode *parent, const char *prefix,
456 const char *task, const char *interval_spec,
457 const char *timeout);
458
459bool pcmk_is_probe(const char *task, guint interval);
460bool pcmk_xe_is_probe(const xmlNode *xml_op);
461bool pcmk_xe_mask_probe_failure(const xmlNode *xml_op);
462
463#ifdef __cplusplus
464}
465#endif
466
467#endif // PCMK__CRM_COMMON_ACTIONS__H
bool pcmk_xe_mask_probe_failure(const xmlNode *xml_op)
Definition actions.c:518
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
Definition actions.c:96
gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc)
Definition actions.c:391
bool pcmk_is_probe(const char *task, guint interval)
Definition actions.c:496
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:272
pe_ordering
Definition actions.h:346
@ pe_order_implies_first_printed
Definition actions.h:363
@ pe_order_implies_first_master
Definition actions.h:372
@ pe_order_trace
Definition actions.h:371
@ pe_order_pseudo_left
Definition actions.h:356
@ pe_order_restart
Definition actions.h:359
@ pe_order_anti_colocation
Definition actions.h:368
@ pe_order_implies_then
Definition actions.h:352
@ pe_order_same_node
Definition actions.h:362
@ pe_order_one_or_more
Definition actions.h:367
@ pe_order_none
Definition actions.h:347
@ pe_order_then_cancels_first
Definition actions.h:370
@ pe_order_serialize_only
Definition actions.h:361
@ pe_order_implies_then_on_node
Definition actions.h:357
@ pe_order_stonith_stop
Definition actions.h:360
@ pe_order_asymmetrical
Definition actions.h:365
@ pe_order_implies_first_migratable
Definition actions.h:354
@ pe_order_preserve
Definition actions.h:369
@ pe_order_implies_then_printed
Definition actions.h:364
@ pe_order_optional
Definition actions.h:349
@ pe_order_implies_first
Definition actions.h:351
@ pe_order_runnable_left
Definition actions.h:355
@ pe_order_probe
Definition actions.h:358
@ pe_order_promoted_implies_first
Definition actions.h:353
@ pe_order_load
Definition actions.h:366
@ pe_order_apply_first_non_migratable
Definition actions.h:350
pe_link_state
Definition actions.h:338
@ pe_link_not_dumped
Definition actions.h:339
@ pe_link_dumped
Definition actions.h:340
@ pe_link_dup
Definition actions.h:342
action_fail_response
Possible responses to a resource action failure.
Definition actions.h:149
@ action_fail_block
Definition actions.h:210
@ pcmk_on_fail_ban
Ban resource from current node.
Definition actions.h:169
@ pcmk_on_fail_fence_node
Fence resource's node.
Definition actions.h:181
@ pcmk_on_fail_ignore
Act as if failure didn't happen.
Definition actions.h:163
@ action_fail_reset_remote
Definition actions.h:225
@ pcmk_on_fail_restart_container
Restart resource's container.
Definition actions.h:186
@ action_fail_migrate
Definition actions.h:207
@ pcmk_on_fail_demote
Demote if promotable, else stop.
Definition actions.h:197
@ pcmk_on_fail_standby_node
Put resource's node in standby.
Definition actions.h:178
@ action_fail_ignore
Definition actions.h:201
@ pcmk_on_fail_block
Treat resource as unmanaged.
Definition actions.h:172
@ action_fail_restart_container
Definition actions.h:222
@ action_fail_fence
Definition actions.h:219
@ pcmk_on_fail_reset_remote
Definition actions.h:194
@ pcmk_on_fail_stop
Stop resource and leave stopped.
Definition actions.h:175
@ pcmk_on_fail_restart
Restart resource.
Definition actions.h:166
@ action_fail_standby
Definition actions.h:216
@ action_fail_demote
Definition actions.h:228
@ action_fail_stop
Definition actions.h:213
@ action_fail_recover
Definition actions.h:204
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:428
pe_action_flags
Action scheduling flags.
Definition actions.h:233
@ pe_action_optional
Definition actions.h:288
@ pe_action_clear
Definition actions.h:309
@ pe_action_tracking
Definition actions.h:321
@ pcmk_action_detect_loop
Whether action has already been processed by a recursive procedure.
Definition actions.h:272
@ pe_action_processed
Definition actions.h:306
@ pcmk_action_runnable
Whether action is runnable.
Definition actions.h:241
@ pcmk_action_reschedule
Whether action is recurring monitor that must be rescheduled if active.
Definition actions.h:269
@ pe_action_runnable
Definition actions.h:285
@ pcmk_action_migratable
Whether action is allowed to be part of a live migration.
Definition actions.h:253
@ pcmk_action_added_to_graph
Whether action has been added to transition graph.
Definition actions.h:256
@ pcmk_action_pseudo
Whether action does not require invoking an agent.
Definition actions.h:238
@ pe_action_implied_by_stonith
Definition actions.h:297
@ pcmk_action_attrs_evaluated
Whether operation-specific instance attributes have been unpacked yet.
Definition actions.h:250
@ pe_action_dumped
Definition actions.h:303
@ pe_action_dedup
Definition actions.h:324
@ pe_action_dangle
Definition actions.h:312
@ pcmk_action_optional
Whether action should not be executed.
Definition actions.h:244
@ pcmk_action_migration_abort
Whether action is a stop to abort a dangling migration.
Definition actions.h:259
@ pe_action_pseudo
Definition actions.h:282
@ pcmk_action_on_dc
Whether action can be executed on DC rather than own node.
Definition actions.h:278
@ pe_action_have_node_attrs
Definition actions.h:294
@ pcmk_action_min_runnable
Definition actions.h:266
@ pcmk_no_action_flags
No action flags set (compare with equality rather than bit set)
Definition actions.h:235
@ pcmk_action_always_in_graph
Whether action should be added to transition graph even if optional.
Definition actions.h:247
@ pe_action_print_always
Definition actions.h:291
@ pcmk_action_inputs_deduplicated
Whether action's inputs have been de-duplicated yet.
Definition actions.h:275
@ pe_action_reschedule
Definition actions.h:318
@ pe_action_requires_any
Definition actions.h:315
@ pe_action_dc
Definition actions.h:327
@ pe_action_migrate_runnable
Definition actions.h:300
action_tasks
Possible actions (including some pseudo-actions)
Definition actions.h:79
@ pcmk_action_start
Start.
Definition actions.h:88
@ pcmk_action_fence
Fence node.
Definition actions.h:101
@ pcmk_action_demote
Demote.
Definition actions.h:97
@ no_action
Definition actions.h:105
@ pcmk_action_stopped
Stop completed.
Definition actions.h:86
@ pcmk_action_promote
Promote.
Definition actions.h:94
@ started_rsc
Definition actions.h:120
@ pcmk_action_started
Start completed.
Definition actions.h:89
@ pcmk_action_notified
Notify completed.
Definition actions.h:92
@ shutdown_crm
Definition actions.h:141
@ start_rsc
Definition actions.h:117
@ action_demote
Definition actions.h:135
@ stonith_node
Definition actions.h:144
@ action_demoted
Definition actions.h:138
@ action_notified
Definition actions.h:126
@ stop_rsc
Definition actions.h:111
@ pcmk_action_demoted
Demoted.
Definition actions.h:98
@ pcmk_action_stop
Stop.
Definition actions.h:85
@ action_promote
Definition actions.h:129
@ pcmk_action_shutdown
Shut down node.
Definition actions.h:100
@ monitor_rsc
Definition actions.h:108
@ pcmk_action_unspecified
Unspecified or unknown action.
Definition actions.h:80
@ action_promoted
Definition actions.h:132
@ pcmk_action_promoted
Promoted.
Definition actions.h:95
@ pcmk_action_notify
Notify.
Definition actions.h:91
@ pcmk_action_monitor
Monitor.
Definition actions.h:81
@ stopped_rsc
Definition actions.h:114
@ action_notify
Definition actions.h:123
int rsc_op_expected_rc(const lrmd_event_data_t *event)
Definition actions.c:380
bool crm_op_needs_metadata(const char *rsc_class, const char *op)
Check whether an operation requires resource agent meta-data.
Definition actions.c:455
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:209
bool pcmk_xe_is_probe(const xmlNode *xml_op)
Definition actions.c:507
const char * parent
Definition cib.c:27
#define PCMK_ALLOW_DEPRECATED
Allow use of deprecated Pacemaker APIs.
Definition crm.h:44
Resource agent executor events.
Scheduler API for nodes.
unsigned int timeout
Definition pcmk_fence.c:32
Scheduler API for resources.
rsc_start_requirement
What resource needs before it can be recovered from a failed node.
Definition resources.h:58
rsc_role_e
Definition roles.h:27
Type aliases needed to define scheduler objects.
op_status
Implementation of pcmk_action_t.
Definition actions.h:390
pcmk_node_t * node
Node to execute action on, if any.
Definition actions.h:401
char * reason
Readable description of why action is needed.
Definition actions.h:406
int runnable_before
For Pacemaker use only.
Definition actions.h:420
char * uuid
Action key.
Definition actions.h:404
char * task
Action name.
Definition actions.h:403
int priority
Definition actions.h:398
void * action_details
For Pacemaker use only.
Definition actions.h:437
enum rsc_role_e fail_role
Resource role if action fails.
Definition actions.h:413
enum rsc_start_requirement needs
Prerequisite for recovery.
Definition actions.h:411
GList * actions_after
For Pacemaker use only.
Definition actions.h:431
GHashTable * meta
Meta-attributes relevant to action.
Definition actions.h:414
int id
Counter to identify action.
Definition actions.h:391
enum action_fail_response on_fail
Response to failure.
Definition actions.h:412
char * cancel_task
If task is "cancel", the action being cancelled.
Definition actions.h:405
enum pe_action_flags flags
Group of enum pe_action_flags.
Definition actions.h:409
int required_runnable_before
Definition actions.h:427
xmlNode * op_entry
Action XML configuration, if any.
Definition actions.h:402
pcmk_resource_t * rsc
Resource to apply action to, if any.
Definition actions.h:400
GHashTable * extra
Action-specific instance attributes.
Definition actions.h:415
GList * actions_before
For Pacemaker use only.
Definition actions.h:430
enum pe_ordering type
Definition actions.h:380
pcmk_action_t * action
Definition actions.h:385
enum pe_link_state state
Definition actions.h:383
Implementation of pcmk_node_t.
Definition nodes.h:130
Implementation of pcmk_resource_t.
Definition resources.h:399