root/include/crm/pengine/pe_types.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   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_PENGINE_PE_TYPES__H
  11 #  define PCMK__CRM_PENGINE_PE_TYPES__H
  12 
  13 
  14 #  include <stdbool.h>              // bool
  15 #  include <sys/types.h>            // time_t
  16 #  include <libxml/tree.h>          // xmlNode
  17 #  include <glib.h>                 // gboolean, guint, GList, GHashTable
  18 #  include <crm/common/iso8601.h>
  19 #  include <crm/pengine/common.h>
  20 
  21 #ifdef __cplusplus
  22 extern "C" {
  23 #endif
  24 
  25 /*!
  26  * \file
  27  * \brief Data types for cluster status
  28  * \ingroup pengine
  29  */
  30 
  31 typedef struct pe_node_s pe_node_t;
  32 typedef struct pe_action_s pe_action_t;
  33 typedef struct pe_resource_s pe_resource_t;
  34 typedef struct pe_working_set_s pe_working_set_t;
  35 
  36 enum pe_obj_types {
  37     pe_unknown = -1,
  38     pe_native = 0,
  39     pe_group = 1,
  40     pe_clone = 2,
  41     pe_container = 3,
  42 };
  43 
  44 typedef struct resource_object_functions_s {
  45     gboolean (*unpack) (pe_resource_t*, pe_working_set_t*);
  46     pe_resource_t *(*find_rsc) (pe_resource_t *parent, const char *search,
  47                                 const pe_node_t *node, int flags);
  48     /* parameter result must be free'd */
  49     char *(*parameter) (pe_resource_t*, pe_node_t*, gboolean, const char*,
  50                         pe_working_set_t*);
  51     //! \deprecated will be removed in a future release
  52     void (*print) (pe_resource_t*, const char*, long, void*);
  53     gboolean (*active) (pe_resource_t*, gboolean);
  54     enum rsc_role_e (*state) (const pe_resource_t*, gboolean);
  55     pe_node_t *(*location) (const pe_resource_t*, GList**, int);
  56     void (*free) (pe_resource_t*);
  57     void (*count) (pe_resource_t*);
  58     gboolean (*is_filtered) (const pe_resource_t*, GList *, gboolean);
  59 
  60     /*!
  61      * \brief
  62      * \internal Find a node (and optionally count all) where resource is active
  63      *
  64      * \param[in]  rsc          Resource to check
  65      * \param[out] count_all    If not NULL, set this to count of active nodes
  66      * \param[out] count_clean  If not NULL, set this to count of clean nodes
  67      *
  68      * \return A node where the resource is active, preferring the source node
  69      *         if the resource is involved in a partial migration or a clean,
  70      *         online node if the resource's "requires" is "quorum" or
  71      *         "nothing", or NULL if the resource is inactive.
  72      */
  73     pe_node_t *(*active_node)(const pe_resource_t *rsc, unsigned int *count_all,
  74                               unsigned int *count_clean);
  75 } resource_object_functions_t;
  76 
  77 typedef struct resource_alloc_functions_s resource_alloc_functions_t;
  78 
  79 enum pe_quorum_policy {
  80     no_quorum_freeze,
  81     no_quorum_stop,
  82     no_quorum_ignore,
  83     no_quorum_suicide,
  84     no_quorum_demote
  85 };
  86 
  87 enum node_type {
  88     node_ping,      //! \deprecated Do not use
  89     node_member,
  90     node_remote
  91 };
  92 
  93 //! \deprecated will be removed in a future release
  94 enum pe_restart {
  95     pe_restart_restart, //! \deprecated will be removed in a future release
  96     pe_restart_ignore   //! \deprecated will be removed in a future release
  97 };
  98 
  99 //! Determine behavior of pe_find_resource_with_flags()
 100 enum pe_find {
 101     pe_find_renamed  = 0x001, //!< match resource ID or LRM history ID
 102     pe_find_anon     = 0x002, //!< match base name of anonymous clone instances
 103     pe_find_clone    = 0x004, //!< match only clone instances
 104     pe_find_current  = 0x008, //!< match resource active on specified node
 105     pe_find_inactive = 0x010, //!< match resource not running anywhere
 106     pe_find_any      = 0x020, //!< match base name of any clone instance
 107 };
 108 
 109 // @TODO Make these an enum
 110 
 111 #  define pe_flag_have_quorum           0x00000001ULL
 112 #  define pe_flag_symmetric_cluster     0x00000002ULL
 113 #  define pe_flag_maintenance_mode      0x00000008ULL
 114 
 115 #  define pe_flag_stonith_enabled       0x00000010ULL
 116 #  define pe_flag_have_stonith_resource 0x00000020ULL
 117 #  define pe_flag_enable_unfencing      0x00000040ULL
 118 #  define pe_flag_concurrent_fencing    0x00000080ULL
 119 
 120 #  define pe_flag_stop_rsc_orphans      0x00000100ULL
 121 #  define pe_flag_stop_action_orphans   0x00000200ULL
 122 #  define pe_flag_stop_everything       0x00000400ULL
 123 
 124 #  define pe_flag_start_failure_fatal   0x00001000ULL
 125 
 126 //! \deprecated
 127 #  define pe_flag_remove_after_stop     0x00002000ULL
 128 
 129 #  define pe_flag_startup_fencing       0x00004000ULL
 130 #  define pe_flag_shutdown_lock         0x00008000ULL
 131 
 132 #  define pe_flag_startup_probes        0x00010000ULL
 133 #  define pe_flag_have_status           0x00020000ULL
 134 #  define pe_flag_have_remote_nodes     0x00040000ULL
 135 
 136 #  define pe_flag_quick_location        0x00100000ULL
 137 #  define pe_flag_sanitized             0x00200000ULL
 138 
 139 //! \deprecated
 140 #  define pe_flag_stdout                0x00400000ULL
 141 
 142 //! Don't count total, disabled and blocked resource instances
 143 #  define pe_flag_no_counts             0x00800000ULL
 144 
 145 /*! Skip deprecated code that is kept solely for backward API compatibility.
 146  * (Internal code should always set this.)
 147  */
 148 #  define pe_flag_no_compat             0x01000000ULL
 149 
 150 #  define pe_flag_show_scores           0x02000000ULL
 151 #  define pe_flag_show_utilization      0x04000000ULL
 152 
 153 /*!
 154  * When scheduling, only unpack the CIB (including constraints), calculate
 155  * as much cluster status as possible, and apply node health.
 156  */
 157 #  define pe_flag_check_config          0x08000000ULL
 158 
 159 struct pe_working_set_s {
 160     xmlNode *input;
 161     crm_time_t *now;
 162 
 163     /* options extracted from the input */
 164     char *dc_uuid;
 165     pe_node_t *dc_node;
 166     const char *stonith_action;
 167     const char *placement_strategy;
 168 
 169     unsigned long long flags;
 170 
 171     int stonith_timeout;
 172     enum pe_quorum_policy no_quorum_policy;
 173 
 174     GHashTable *config_hash;
 175     GHashTable *tickets;
 176 
 177     // Actions for which there can be only one (e.g. fence nodeX)
 178     GHashTable *singletons;
 179 
 180     GList *nodes;
 181     GList *resources;
 182     GList *placement_constraints;
 183     GList *ordering_constraints;
 184     GList *colocation_constraints;
 185     GList *ticket_constraints;
 186 
 187     GList *actions;
 188     xmlNode *failed;
 189     xmlNode *op_defaults;
 190     xmlNode *rsc_defaults;
 191 
 192     /* stats */
 193     int num_synapse;
 194     int max_valid_nodes;    //! Deprecated (will be removed in a future release)
 195     int order_id;
 196     int action_id;
 197 
 198     /* final output */
 199     xmlNode *graph;
 200 
 201     GHashTable *template_rsc_sets;
 202     const char *localhost;
 203     GHashTable *tags;
 204 
 205     int blocked_resources;
 206     int disabled_resources;
 207 
 208     GList *param_check; // History entries that need to be checked
 209     GList *stop_needed; // Containers that need stop actions
 210     time_t recheck_by;  // Hint to controller to re-run scheduler by this time
 211     int ninstances;     // Total number of resource instances
 212     guint shutdown_lock;// How long (seconds) to lock resources to shutdown node
 213     int priority_fencing_delay; // Priority fencing delay
 214 
 215     void *priv;
 216 };
 217 
 218 enum pe_check_parameters {
 219     /* Clear fail count if parameters changed for un-expired start or monitor
 220      * last_failure.
 221      */
 222     pe_check_last_failure,
 223 
 224     /* Clear fail count if parameters changed for start, monitor, promote, or
 225      * migrate_from actions for active resources.
 226      */
 227     pe_check_active,
 228 };
 229 
 230 struct pe_node_shared_s {
 231     const char *id;
 232     const char *uname;
 233     enum node_type type;
 234 
 235     /* @TODO convert these flags into a bitfield */
 236     gboolean online;
 237     gboolean standby;
 238     gboolean standby_onfail;
 239     gboolean pending;
 240     gboolean unclean;
 241     gboolean unseen;
 242     gboolean shutdown;
 243     gboolean expected_up;
 244     gboolean is_dc;
 245     gboolean maintenance;
 246     gboolean rsc_discovery_enabled;
 247     gboolean remote_requires_reset;
 248     gboolean remote_was_fenced;
 249     gboolean remote_maintenance; /* what the remote-rsc is thinking */
 250     gboolean unpacked;
 251 
 252     int num_resources;
 253     pe_resource_t *remote_rsc;
 254     GList *running_rsc;       /* pe_resource_t* */
 255     GList *allocated_rsc;     /* pe_resource_t* */
 256 
 257     GHashTable *attrs;          /* char* => char* */
 258     GHashTable *utilization;
 259     GHashTable *digest_cache;   //!< cache of calculated resource digests
 260     int priority; // calculated based on the priority of resources running on the node
 261     pe_working_set_t *data_set; //!< Cluster that this node is part of
 262 };
 263 
 264 struct pe_node_s {
 265     int weight;
 266     gboolean fixed; //!< \deprecated Will be removed in a future release
 267     int count;
 268     struct pe_node_shared_s *details;
 269     int rsc_discover_mode;
 270 };
 271 
 272 #  define pe_rsc_orphan                     0x00000001ULL
 273 #  define pe_rsc_managed                    0x00000002ULL
 274 #  define pe_rsc_block                      0x00000004ULL
 275 #  define pe_rsc_orphan_container_filler    0x00000008ULL
 276 
 277 #  define pe_rsc_notify                     0x00000010ULL
 278 #  define pe_rsc_unique                     0x00000020ULL
 279 #  define pe_rsc_fence_device               0x00000040ULL
 280 #  define pe_rsc_promotable                 0x00000080ULL
 281 
 282 #  define pe_rsc_provisional                0x00000100ULL
 283 #  define pe_rsc_allocating                 0x00000200ULL
 284 #  define pe_rsc_merging                    0x00000400ULL
 285 #  define pe_rsc_restarting                 0x00000800ULL
 286 
 287 #  define pe_rsc_stop                       0x00001000ULL
 288 #  define pe_rsc_reload                     0x00002000ULL
 289 #  define pe_rsc_allow_remote_remotes       0x00004000ULL
 290 #  define pe_rsc_critical                   0x00008000ULL
 291 
 292 #  define pe_rsc_failed                     0x00010000ULL
 293 #  define pe_rsc_detect_loop                0x00020000ULL
 294 #  define pe_rsc_runnable                   0x00040000ULL
 295 #  define pe_rsc_start_pending              0x00080000ULL
 296 
 297 //!< \deprecated Do not use
 298 #  define pe_rsc_starting                   0x00100000ULL
 299 
 300 //!< \deprecated Do not use
 301 #  define pe_rsc_stopping                   0x00200000ULL
 302 
 303 #  define pe_rsc_stop_unexpected            0x00400000ULL
 304 #  define pe_rsc_allow_migrate              0x00800000ULL
 305 
 306 #  define pe_rsc_failure_ignored            0x01000000ULL
 307 #  define pe_rsc_replica_container          0x02000000ULL
 308 #  define pe_rsc_maintenance                0x04000000ULL
 309 #  define pe_rsc_is_container               0x08000000ULL
 310 
 311 #  define pe_rsc_needs_quorum               0x10000000ULL
 312 #  define pe_rsc_needs_fencing              0x20000000ULL
 313 #  define pe_rsc_needs_unfencing            0x40000000ULL
 314 
 315 /* *INDENT-OFF* */
 316 enum pe_action_flags {
 317     pe_action_pseudo = 0x00001,
 318     pe_action_runnable = 0x00002,
 319     pe_action_optional = 0x00004,
 320     pe_action_print_always = 0x00008,
 321 
 322     pe_action_have_node_attrs = 0x00010,
 323     pe_action_implied_by_stonith = 0x00040,
 324     pe_action_migrate_runnable =   0x00080,
 325 
 326     pe_action_dumped = 0x00100,
 327     pe_action_processed = 0x00200,
 328 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
 329     pe_action_clear = 0x00400, //! \deprecated Unused
 330 #endif
 331     pe_action_dangle = 0x00800,
 332 
 333     /* This action requires one or more of its dependencies to be runnable.
 334      * We use this to clear the runnable flag before checking dependencies.
 335      */
 336     pe_action_requires_any = 0x01000,
 337 
 338     pe_action_reschedule = 0x02000,
 339     pe_action_tracking = 0x04000,
 340     pe_action_dedup = 0x08000, //! Internal state tracking when creating graph
 341 
 342     pe_action_dc = 0x10000,         //! Action may run on DC instead of target
 343 };
 344 /* *INDENT-ON* */
 345 
 346 struct pe_resource_s {
 347     char *id;
 348     char *clone_name;
 349     xmlNode *xml;
 350     xmlNode *orig_xml;
 351     xmlNode *ops_xml;
 352 
 353     pe_working_set_t *cluster;
 354     pe_resource_t *parent;
 355 
 356     enum pe_obj_types variant;
 357     void *variant_opaque;
 358     resource_object_functions_t *fns;
 359     resource_alloc_functions_t *cmds;
 360 
 361     enum rsc_recovery_type recovery_type;
 362 
 363     enum pe_restart restart_type; //!< \deprecated will be removed in future release
 364 
 365     int priority;
 366     int stickiness;
 367     int sort_index;
 368     int failure_timeout;
 369     int migration_threshold;
 370     guint remote_reconnect_ms;
 371     char *pending_task;
 372 
 373     unsigned long long flags;
 374 
 375     // @TODO merge these into flags
 376     gboolean is_remote_node;
 377     gboolean exclusive_discover;
 378 
 379     /* Pay special attention to whether you want to use rsc_cons_lhs and
 380      * rsc_cons directly, which include only colocations explicitly involving
 381      * this resource, or call libpacemaker's pcmk__with_this_colocations() and
 382      * pcmk__this_with_colocations() functions, which may return relevant
 383      * colocations involving the resource's ancestors as well.
 384      */
 385 
 386     //!@{
 387     //! This field should be treated as internal to Pacemaker
 388     GList *rsc_cons_lhs;      // List of pcmk__colocation_t*
 389     GList *rsc_cons;          // List of pcmk__colocation_t*
 390     GList *rsc_location;      // List of pe__location_t*
 391     GList *actions;           // List of pe_action_t*
 392     GList *rsc_tickets;       // List of rsc_ticket*
 393     //!@}
 394 
 395     pe_node_t *allocated_to;
 396     pe_node_t *partial_migration_target;
 397     pe_node_t *partial_migration_source;
 398     GList *running_on;        /* pe_node_t*   */
 399     GHashTable *known_on;       /* pe_node_t*   */
 400     GHashTable *allowed_nodes;  /* pe_node_t*   */
 401 
 402     enum rsc_role_e role;
 403     enum rsc_role_e next_role;
 404 
 405     GHashTable *meta;
 406     GHashTable *parameters; //! \deprecated Use pe_rsc_params() instead
 407     GHashTable *utilization;
 408 
 409     GList *children;          /* pe_resource_t*   */
 410     GList *dangling_migrations;       /* pe_node_t*       */
 411 
 412     pe_resource_t *container;
 413     GList *fillers;
 414 
 415     // @COMPAT These should be made const at next API compatibility break
 416     pe_node_t *pending_node;    // Node on which pending_task is happening
 417     pe_node_t *lock_node;       // Resource is shutdown-locked to this node
 418 
 419     time_t lock_time;           // When shutdown lock started
 420 
 421     /* Resource parameters may have node-attribute-based rules, which means the
 422      * values can vary by node. This table is a cache of parameter name/value
 423      * tables for each node (as needed). Use pe_rsc_params() to get the table
 424      * for a given node.
 425      */
 426     GHashTable *parameter_cache; // Key = node name, value = parameters table
 427 };
 428 
 429 struct pe_action_s {
 430     int id;
 431     int priority;
 432 
 433     pe_resource_t *rsc;
 434     pe_node_t *node;
 435     xmlNode *op_entry;
 436 
 437     char *task;
 438     char *uuid;
 439     char *cancel_task;
 440     char *reason;
 441 
 442     enum pe_action_flags flags;
 443     enum rsc_start_requirement needs;
 444     enum action_fail_response on_fail;
 445     enum rsc_role_e fail_role;
 446 
 447     GHashTable *meta;
 448     GHashTable *extra;
 449 
 450     /* 
 451      * These two varables are associated with the constraint logic
 452      * that involves first having one or more actions runnable before
 453      * then allowing this action to execute.
 454      *
 455      * These varables are used with features such as 'clone-min' which
 456      * requires at minimum X number of cloned instances to be running
 457      * before an order dependency can run. Another option that uses
 458      * this is 'require-all=false' in ordering constrants. This option
 459      * says "only require one instance of a resource to start before
 460      * allowing dependencies to start" -- basically, require-all=false is
 461      * the same as clone-min=1.
 462      */
 463 
 464     /* current number of known runnable actions in the before list. */
 465     int runnable_before;
 466     /* the number of "before" runnable actions required for this action
 467      * to be considered runnable */ 
 468     int required_runnable_before;
 469 
 470     GList *actions_before;    /* pe_action_wrapper_t* */
 471     GList *actions_after;     /* pe_action_wrapper_t* */
 472 
 473     /* Some of the above fields could be moved to the details,
 474      * except for API backward compatibility.
 475      */
 476     void *action_details; // varies by type of action
 477 };
 478 
 479 typedef struct pe_ticket_s {
 480     char *id;
 481     gboolean granted;
 482     time_t last_granted;
 483     gboolean standby;
 484     GHashTable *state;
 485 } pe_ticket_t;
 486 
 487 typedef struct pe_tag_s {
 488     char *id;
 489     GList *refs;
 490 } pe_tag_t;
 491 
 492 //! Internal tracking for transition graph creation
 493 enum pe_link_state {
 494     pe_link_not_dumped, //! Internal tracking for transition graph creation
 495     pe_link_dumped,     //! Internal tracking for transition graph creation
 496     pe_link_dup,        //! \deprecated No longer used by Pacemaker
 497 };
 498 
 499 enum pe_discover_e {
 500     pe_discover_always = 0,
 501     pe_discover_never,
 502     pe_discover_exclusive,
 503 };
 504 
 505 /* *INDENT-OFF* */
 506 enum pe_ordering {
 507     pe_order_none                  = 0x0,       /* deleted */
 508     pe_order_optional              = 0x1,       /* pure ordering, nothing implied */
 509     pe_order_apply_first_non_migratable = 0x2,  /* Only apply this constraint's ordering if first is not migratable. */
 510 
 511     pe_order_implies_first         = 0x10,      /* If 'then' is required, ensure 'first' is too */
 512     pe_order_implies_then          = 0x20,      /* If 'first' is required, ensure 'then' is too */
 513     pe_order_promoted_implies_first = 0x40,     /* If 'then' is required and then's rsc is promoted, ensure 'first' becomes required too */
 514 
 515     /* first requires then to be both runnable and migrate runnable. */
 516     pe_order_implies_first_migratable  = 0x80,
 517 
 518     pe_order_runnable_left         = 0x100,     /* 'then' requires 'first' to be runnable */
 519 
 520     pe_order_pseudo_left           = 0x200,     /* 'then' can only be pseudo if 'first' is runnable */
 521     pe_order_implies_then_on_node  = 0x400,     /* If 'first' is required on 'nodeX',
 522                                                  * ensure instances of 'then' on 'nodeX' are too.
 523                                                  * Only really useful if 'then' is a clone and 'first' is not
 524                                                  */
 525     pe_order_probe                 = 0x800,     /* If 'first->rsc' is
 526                                                  *  - running but about to stop, ignore the constraint
 527                                                  *  - otherwise, behave as runnable_left
 528                                                  */
 529 
 530     pe_order_restart               = 0x1000,    /* 'then' is runnable if 'first' is optional or runnable */
 531     pe_order_stonith_stop          = 0x2000,    //<! \deprecated Will be removed in future release
 532     pe_order_serialize_only        = 0x4000,    /* serialize */
 533     pe_order_same_node             = 0x8000,    /* applies only if 'first' and 'then' are on same node */
 534 
 535     pe_order_implies_first_printed = 0x10000,   /* Like ..implies_first but only ensures 'first' is printed, not mandatory */
 536     pe_order_implies_then_printed  = 0x20000,   /* Like ..implies_then but only ensures 'then' is printed, not mandatory */
 537 
 538     pe_order_asymmetrical          = 0x100000,  /* Indicates asymmetrical one way ordering constraint. */
 539     pe_order_load                  = 0x200000,  /* Only relevant if... */
 540     pe_order_one_or_more           = 0x400000,  /* 'then' is runnable only if one or more of its dependencies are too */
 541     pe_order_anti_colocation       = 0x800000,
 542 
 543     pe_order_preserve              = 0x1000000, /* Hack for breaking user ordering constraints with container resources */
 544     pe_order_then_cancels_first    = 0x2000000, // if 'then' becomes required, 'first' becomes optional
 545     pe_order_trace                 = 0x4000000, /* test marker */
 546 
 547 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
 548     // \deprecated Use pe_order_promoted_implies_first instead
 549     pe_order_implies_first_master  = pe_order_promoted_implies_first,
 550 #endif
 551 };
 552 /* *INDENT-ON* */
 553 
 554 typedef struct pe_action_wrapper_s {
 555     enum pe_ordering type;
 556     enum pe_link_state state;
 557     pe_action_t *action;
 558 } pe_action_wrapper_t;
 559 
 560 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
 561 #include <crm/pengine/pe_types_compat.h>
 562 #endif
 563 
 564 #ifdef __cplusplus
 565 }
 566 #endif
 567 
 568 #endif // PCMK__CRM_PENGINE_PE_TYPES__H

/* [previous][next][first][last][top][bottom][index][help] */