root/daemons/controld/controld_globals.h

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

INCLUDED FROM


   1 /*
   2  * Copyright 2022-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 CONTROLD_GLOBALS__H
  11 #  define CONTROLD_GLOBALS__H
  12 
  13 #include <crm_internal.h>       // pcmk__output_t, etc.
  14 
  15 #include <stdint.h>             // uint32_t, uint64_t
  16 #include <glib.h>               // GList, GMainLoop
  17 #include <crm/cib.h>            // cib_t
  18 #include <pacemaker-internal.h> // pcmk__graph_t
  19 #include <controld_fsa.h>       // enum crmd_fsa_state
  20 
  21 typedef struct {
  22     // Group of \p controld_flags values
  23     uint32_t flags;
  24 
  25 
  26     /* Controller finite state automaton */
  27 
  28     // FSA state
  29     enum crmd_fsa_state fsa_state;
  30 
  31     // FSA actions (group of \p A_* flags)
  32     uint64_t fsa_actions;
  33 
  34     // FSA input register contents (group of \p R_* flags)
  35     uint64_t fsa_input_register;
  36 
  37     // FSA message queue
  38     GList *fsa_message_queue;
  39 
  40 
  41     /* CIB */
  42 
  43     // Connection to the CIB
  44     cib_t *cib_conn;
  45 
  46 
  47     /* Scheduler */
  48 
  49     // Reference of the scheduler request being waited on
  50     char *fsa_pe_ref;
  51 
  52 
  53     /* Transitioner */
  54 
  55     // Transitioner UUID
  56     char *te_uuid;
  57 
  58     // Graph of transition currently being processed
  59     pcmk__graph_t *transition_graph;
  60 
  61 
  62     /* Logging */
  63 
  64     // Output object for controller log messages
  65     pcmk__output_t *logger_out;
  66 
  67 
  68     /* Cluster layer */
  69 
  70     // Cluster name
  71     char *cluster_name;
  72 
  73     // Cluster connection
  74     pcmk_cluster_t *cluster;
  75 
  76     /* @TODO Figure out, document, and clean up the code involving
  77      * controld_globals.membership_id, controld_globals.peer_seq, and
  78      * highest_seq. It's convoluted with no comments. It has something to do
  79      * with corosync quorum notifications and the current ring ID, but it's
  80      * unclear why we need three separate variables for it.
  81      */
  82     // Last saved cluster communication layer membership ID
  83     unsigned long long membership_id;
  84 
  85     unsigned long long peer_seq;
  86 
  87 
  88     /* Other */
  89 
  90     // Designated controller name
  91     char *dc_name;
  92 
  93     // Designated controller's Pacemaker version
  94     char *dc_version;
  95 
  96     // Local node's UUID
  97     char *our_uuid;
  98 
  99     // Max lifetime (in seconds) of a resource's shutdown lock to a node
 100     guint shutdown_lock_limit;
 101 
 102     // Node pending timeout
 103     guint node_pending_timeout;
 104 
 105     // Main event loop
 106     GMainLoop *mainloop;
 107 } controld_globals_t;
 108 
 109 extern controld_globals_t controld_globals;
 110 
 111 /*!
 112  * \internal
 113  * \enum controld_flags
 114  * \brief Bit flags to store various controller state and configuration info
 115  */
 116 enum controld_flags {
 117     //! The DC left in a membership change that is being processed
 118     controld_dc_left                = (1 << 0),
 119 
 120     //! The FSA is stalled waiting for further input
 121     controld_fsa_is_stalled         = (1 << 1),
 122 
 123     //! The local node has been in a quorate partition at some point
 124     controld_ever_had_quorum        = (1 << 2),
 125 
 126     //! The local node is currently in a quorate partition
 127     controld_has_quorum             = (1 << 3),
 128 
 129     //! Panic the local node if it loses quorum
 130     controld_no_quorum_panic        = (1 << 4),
 131 
 132     //! Lock resources to the local node when it shuts down cleanly
 133     controld_shutdown_lock_enabled  = (1 << 5),
 134 };
 135 
 136 #  define controld_set_global_flags(flags_to_set) do {                      \
 137         controld_globals.flags = pcmk__set_flags_as(__func__, __LINE__,     \
 138                                                     LOG_TRACE,              \
 139                                                     "Global", "controller", \
 140                                                     controld_globals.flags, \
 141                                                     (flags_to_set),         \
 142                                                     #flags_to_set);         \
 143     } while (0)
 144 
 145 #  define controld_clear_global_flags(flags_to_clear) do {                  \
 146         controld_globals.flags                                              \
 147             = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE, "Global", \
 148                                    "controller", controld_globals.flags,    \
 149                                    (flags_to_clear), #flags_to_clear);      \
 150     } while (0)
 151 
 152 #endif  // ifndef CONTROLD_GLOBALS__H

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