root/include/pcmki/pcmki_transition.h

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

INCLUDED FROM


   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__PCMKI_PCMKI_TRANSITION__H
  11 #define PCMK__PCMKI_PCMKI_TRANSITION__H
  12 
  13 #include <stdbool.h>                    // bool
  14 #include <stdint.h>                     // uint32_t
  15 #include <sys/types.h>                  // time_t
  16 #include <glib.h>                       // guint, GList, GHashTable
  17 #include <libxml/tree.h>                // xmlNode
  18 
  19 #include <crm/common/scheduler_types.h> // pcmk_scheduler_t
  20 #include <crm/lrmd_events.h>            // lrmd_event_data_t
  21 
  22 #ifdef __cplusplus
  23 extern "C" {
  24 #endif
  25 
  26 enum pcmk__graph_action_type {
  27     pcmk__pseudo_graph_action,
  28     pcmk__rsc_graph_action,
  29     pcmk__cluster_graph_action,
  30     /* @TODO maybe separate a new pcmk__fencing_graph_action from
  31      * pcmk__cluster_graph_action to make code cleaner (for example, see
  32      * initiate_action())
  33      */
  34 };
  35 
  36 enum pcmk__synapse_flags {
  37     pcmk__synapse_ready       = (1 << 0),
  38     pcmk__synapse_failed      = (1 << 1),
  39     pcmk__synapse_executed    = (1 << 2),
  40     pcmk__synapse_confirmed   = (1 << 3),
  41 };
  42 
  43 typedef struct {
  44     int id;
  45     int priority;
  46 
  47     uint32_t flags; // Group of pcmk__synapse_flags
  48 
  49     GList *actions;           /* pcmk__graph_action_t* */
  50     GList *inputs;            /* pcmk__graph_action_t* */
  51 } pcmk__graph_synapse_t;
  52 
  53 #define pcmk__set_synapse_flags(synapse, flags_to_set) do {             \
  54         (synapse)->flags = pcmk__set_flags_as(__func__, __LINE__,       \
  55             LOG_TRACE,                                                  \
  56             "Synapse", "synapse",                       \
  57             (synapse)->flags, (flags_to_set), #flags_to_set);           \
  58     } while (0)
  59 
  60 #define pcmk__clear_synapse_flags(synapse, flags_to_clear) do {         \
  61         (synapse)->flags = pcmk__clear_flags_as(__func__, __LINE__,     \
  62             LOG_TRACE,                                                  \
  63             "Synapse", "synapse",                      \
  64             (synapse)->flags, (flags_to_clear), #flags_to_clear);       \
  65     } while (0)
  66 
  67 enum pcmk__graph_action_flags {
  68     pcmk__graph_action_sent_update   = (1 << 0),     /* sent to the CIB */
  69     pcmk__graph_action_executed      = (1 << 1),     /* sent to the CRM */
  70     pcmk__graph_action_confirmed     = (1 << 2),
  71     pcmk__graph_action_failed        = (1 << 3),
  72 };
  73 
  74 typedef struct {
  75     int id;
  76     int timeout;
  77     int timer;
  78     guint interval_ms;
  79     GHashTable *params;
  80     enum pcmk__graph_action_type type;
  81     pcmk__graph_synapse_t *synapse;
  82 
  83     uint32_t flags; // Group of pcmk__graph_action_flags
  84 
  85     xmlNode *xml;
  86 
  87 } pcmk__graph_action_t;
  88 
  89 #define pcmk__set_graph_action_flags(action, flags_to_set) do {       \
  90         (action)->flags = pcmk__set_flags_as(__func__, __LINE__,      \
  91             LOG_TRACE,                                                \
  92             "Action", "action",                                       \
  93             (action)->flags, (flags_to_set), #flags_to_set);          \
  94     } while (0)
  95 
  96 #define pcmk__clear_graph_action_flags(action, flags_to_clear) do {   \
  97         (action)->flags = pcmk__clear_flags_as(__func__, __LINE__,    \
  98             LOG_TRACE,                                                \
  99             "Action", "action",                                       \
 100             (action)->flags, (flags_to_clear), #flags_to_clear);      \
 101     } while (0)
 102 
 103 // What to do after finished processing a transition graph
 104 enum pcmk__graph_next {
 105     // Order matters: lowest priority to highest
 106     pcmk__graph_done,       // Transition complete, nothing further needed
 107     pcmk__graph_wait,       // Transition interrupted, wait for further changes
 108     pcmk__graph_restart,    // Transition interrupted, start a new one
 109     pcmk__graph_shutdown,   // Transition interrupted, local shutdown needed
 110 };
 111 
 112 typedef struct {
 113     int id;
 114     char *source;
 115     int abort_priority;
 116 
 117     bool complete;
 118     const char *abort_reason;
 119     enum pcmk__graph_next completion_action;
 120 
 121     int num_actions;
 122     int num_synapses;
 123 
 124     int batch_limit;
 125     guint network_delay;
 126     guint stonith_timeout;
 127 
 128     int fired;
 129     int pending;
 130     int skipped;
 131     int completed;
 132     int incomplete;
 133 
 134     GList *synapses;          /* pcmk__graph_synapse_t* */
 135 
 136     int migration_limit;
 137 
 138     //! Failcount after one failed stop action
 139     char *failed_stop_offset;
 140 
 141     //! Failcount after one failed start action
 142     char *failed_start_offset;
 143 
 144     //! Time (from epoch) by which the controller should re-run the scheduler
 145     time_t recheck_by;
 146 } pcmk__graph_t;
 147 
 148 
 149 typedef struct {
 150     int (*pseudo) (pcmk__graph_t *graph, pcmk__graph_action_t *action);
 151     int (*rsc) (pcmk__graph_t *graph, pcmk__graph_action_t *action);
 152     int (*cluster) (pcmk__graph_t *graph, pcmk__graph_action_t *action);
 153     int (*fence) (pcmk__graph_t *graph, pcmk__graph_action_t *action);
 154     bool (*allowed) (pcmk__graph_t *graph, pcmk__graph_action_t *action);
 155 } pcmk__graph_functions_t;
 156 
 157 enum pcmk__graph_status {
 158     pcmk__graph_active,     // Some actions have been performed
 159     pcmk__graph_pending,    // No actions performed yet
 160     pcmk__graph_complete,
 161     pcmk__graph_terminated,
 162 };
 163 
 164 void pcmk__set_graph_functions(pcmk__graph_functions_t *fns);
 165 pcmk__graph_t *pcmk__unpack_graph(const xmlNode *xml_graph,
 166                                   const char *reference);
 167 enum pcmk__graph_status pcmk__execute_graph(pcmk__graph_t *graph);
 168 void pcmk__update_graph(pcmk__graph_t *graph,
 169                         const pcmk__graph_action_t *action);
 170 void pcmk__free_graph(pcmk__graph_t *graph);
 171 const char *pcmk__graph_status2text(enum pcmk__graph_status state);
 172 void pcmk__log_graph(unsigned int log_level, pcmk__graph_t *graph);
 173 void pcmk__log_graph_action(int log_level, pcmk__graph_action_t *action);
 174 void pcmk__log_transition_summary(const pcmk_scheduler_t *scheduler,
 175                                   const char *filename);
 176 lrmd_event_data_t *pcmk__event_from_graph_action(const xmlNode *resource,
 177                                                  const pcmk__graph_action_t *action,
 178                                                  int status, int rc,
 179                                                  const char *exit_reason);
 180 
 181 #ifdef __cplusplus
 182 }
 183 #endif
 184 
 185 #endif // PCMK__PCMKI_PCMKI_TRANSITION__H

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