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