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

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