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

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