pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
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
28 extern "C" {
29 #endif
30 
37 #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 
82 
83  // Each "completed" action must be the regular action plus 1
84 
87 
90 
93 
96 
99 
102 
103 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
106 
109 
112 
115 
118 
121 
124 
127 
130 
133 
136 
139 
142 
145 #endif
146 };
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 
238  pcmk_action_pseudo = (1 << 0),
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 
348 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
358  pe_order_probe = 0x800,
366  pe_order_load = 0x200000,
369  pe_order_preserve = 0x1000000,
371  pe_order_trace = 0x4000000,
373 #endif
374 };
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 
390 struct pe_action_s {
391  int id;
392 
398  int priority;
399 
402  xmlNode *op_entry;
403  char *task;
404  char *uuid;
405  char *cancel_task;
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 *)
430  GList *actions_before;
431  GList *actions_after;
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
441 gboolean parse_op_key(const char *key, char **rsc_id, char **op_type,
442  guint *interval_ms);
443 gboolean decode_transition_key(const char *key, char **uuid, int *transition_id,
444  int *action_id, int *target_rc);
445 gboolean 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
450 int rsc_op_expected_rc(const lrmd_event_data_t *event);
451 gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc);
452 
453 bool crm_op_needs_metadata(const char *rsc_class, const char *op);
454 
455 xmlNode *crm_create_op_xml(xmlNode *parent, const char *prefix,
456  const char *task, const char *interval_spec,
457  const char *timeout);
458 
459 bool pcmk_is_probe(const char *task, guint interval);
460 bool pcmk_xe_is_probe(const xmlNode *xml_op);
461 bool pcmk_xe_mask_probe_failure(const xmlNode *xml_op);
462 
463 #ifdef __cplusplus
464 }
465 #endif
466 
467 #endif // PCMK__CRM_COMMON_ACTIONS__H
enum pe_link_state state
Definition: actions.h:383
Demoted.
Definition: actions.h:98
enum rsc_start_requirement needs
Prerequisite for recovery.
Definition: actions.h:411
Scheduler API for resources.
Whether action should not be executed.
Definition: actions.h:244
int runnable_before
For Pacemaker use only.
Definition: actions.h:420
Monitor.
Definition: actions.h:81
int priority
Definition: actions.h:398
Type aliases needed to define scheduler objects.
pcmk_action_t * action
Definition: actions.h:385
Whether action has already been processed by a recursive procedure.
Definition: actions.h:272
Notify.
Definition: actions.h:91
Ban resource from current node.
Definition: actions.h:169
pe_ordering
Definition: actions.h:346
enum action_fail_response on_fail
Response to failure.
Definition: actions.h:412
Fence resource&#39;s node.
Definition: actions.h:181
bool pcmk_is_probe(const char *task, guint interval)
Definition: actions.c:496
Implementation of pcmk_action_t.
Definition: actions.h:390
char * cancel_task
If task is "cancel", the action being cancelled.
Definition: actions.h:405
pe_link_state
Definition: actions.h:338
action_tasks
Possible actions (including some pseudo-actions)
Definition: actions.h:79
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
action_fail_response
Possible responses to a resource action failure.
Definition: actions.h:149
xmlNode * op_entry
Action XML configuration, if any.
Definition: actions.h:402
int id
Counter to identify action.
Definition: actions.h:391
Demote if promotable, else stop.
Definition: actions.h:197
char * reason
Readable description of why action is needed.
Definition: actions.h:406
void * action_details
For Pacemaker use only.
Definition: actions.h:437
GHashTable * extra
Action-specific instance attributes.
Definition: actions.h:415
rsc_start_requirement
What resource needs before it can be recovered from a failed node.
Definition: resources.h:58
bool pcmk_xe_is_probe(const xmlNode *xml_op)
Definition: actions.c:507
Whether action&#39;s inputs have been de-duplicated yet.
Definition: actions.h:275
Notify completed.
Definition: actions.h:92
Stop resource and leave stopped.
Definition: actions.h:175
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
gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc)
Definition: actions.c:391
No action flags set (compare with equality rather than bit set)
Definition: actions.h:235
Put resource&#39;s node in standby.
Definition: actions.h:178
op_status
Promote.
Definition: actions.h:94
pcmk_node_t * node
Node to execute action on, if any.
Definition: actions.h:401
Restart resource&#39;s container.
Definition: actions.h:186
int rsc_op_expected_rc(const lrmd_event_data_t *event)
Definition: actions.c:380
Implementation of pcmk_resource_t.
Definition: resources.h:399
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
Demote.
Definition: actions.h:97
char * task
Action name.
Definition: actions.h:403
GList * actions_after
For Pacemaker use only.
Definition: actions.h:431
bool pcmk_xe_mask_probe_failure(const xmlNode *xml_op)
Definition: actions.c:518
GHashTable * meta
Meta-attributes relevant to action.
Definition: actions.h:414
rsc_role_e
Definition: roles.h:27
pe_action_flags
Action scheduling flags.
Definition: actions.h:233
Shut down node.
Definition: actions.h:100
char * uuid
Action key.
Definition: actions.h:404
Implementation of pcmk_node_t.
Definition: nodes.h:130
#define PCMK_ALLOW_DEPRECATED
Allow use of deprecated Pacemaker APIs.
Definition: crm.h:44
Fence node.
Definition: actions.h:101
Unspecified or unknown action.
Definition: actions.h:80
Scheduler API for nodes.
Whether action is runnable.
Definition: actions.h:241
Whether action does not require invoking an agent.
Definition: actions.h:238
Whether action should be added to transition graph even if optional.
Definition: actions.h:247
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
Definition: actions.c:96
enum rsc_role_e fail_role
Resource role if action fails.
Definition: actions.h:413
Whether operation-specific instance attributes have been unpacked yet.
Definition: actions.h:250
enum pe_action_flags flags
Group of enum pe_action_flags.
Definition: actions.h:409
Start completed.
Definition: actions.h:89
Whether action is allowed to be part of a live migration.
Definition: actions.h:253
Whether action has been added to transition graph.
Definition: actions.h:256
Whether action is a stop to abort a dangling migration.
Definition: actions.h:259
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
pcmk_resource_t * rsc
Resource to apply action to, if any.
Definition: actions.h:400
Stop completed.
Definition: actions.h:86
Treat resource as unmanaged.
Definition: actions.h:172
Whether action is recurring monitor that must be rescheduled if active.
Definition: actions.h:269
Whether action can be executed on DC rather than own node.
Definition: actions.h:278
const char * parent
Definition: cib.c:27
Resource agent executor events.
Promoted.
Definition: actions.h:95
Restart resource.
Definition: actions.h:166
enum pe_ordering type
Definition: actions.h:380
unsigned int timeout
Definition: pcmk_fence.c:32
GList * actions_before
For Pacemaker use only.
Definition: actions.h:430
Act as if failure didn&#39;t happen.
Definition: actions.h:163
int required_runnable_before
Definition: actions.h:427