root/daemons/controld/controld_lrm.h

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

INCLUDED FROM


   1 /*
   2  * Copyright 2004-2020 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 #ifndef CONTROLD_LRM__H
  10 #  define CONTROLD_LRM__H
  11 
  12 #include <controld_messages.h>
  13 #include <controld_metadata.h>
  14 
  15 extern gboolean verify_stopped(enum crmd_fsa_state cur_state, int log_level);
  16 void lrm_clear_last_failure(const char *rsc_id, const char *node_name,
  17                             const char *operation, guint interval_ms);
  18 void lrm_op_callback(lrmd_event_data_t * op);
  19 lrmd_t *crmd_local_lrmd_conn(void);
  20 
  21 typedef struct resource_history_s {
  22     char *id;
  23     uint32_t last_callid;
  24     lrmd_rsc_info_t rsc;
  25     lrmd_event_data_t *last;
  26     lrmd_event_data_t *failed;
  27     GList *recurring_op_list;
  28 
  29     /* Resources must be stopped using the same
  30      * parameters they were started with.  This hashtable
  31      * holds the parameters that should be used for the next stop
  32      * cmd on this resource. */
  33     GHashTable *stop_params;
  34 } rsc_history_t;
  35 
  36 void history_free(gpointer data);
  37 
  38 enum active_op_e {
  39     active_op_remove    = (1 << 0),
  40     active_op_cancelled = (1 << 1),
  41 };
  42 
  43 // In-flight action (recurring or pending)
  44 typedef struct active_op_s {
  45     guint interval_ms;
  46     int call_id;
  47     uint32_t flags; // bitmask of active_op_e
  48     time_t start_time;
  49     time_t lock_time;
  50     char *rsc_id;
  51     char *op_type;
  52     char *op_key;
  53     char *user_data;
  54     GHashTable *params;
  55 } active_op_t;
  56 
  57 #define controld_set_active_op_flags(active_op, flags_to_set) do {          \
  58         (active_op)->flags = pcmk__set_flags_as(__func__, __LINE__,         \
  59             LOG_TRACE, "Active operation", (active_op)->op_key,             \
  60             (active_op)->flags, (flags_to_set), #flags_to_set);             \
  61     } while (0)
  62 
  63 #define controld_clear_active_op_flags(active_op, flags_to_clear) do {      \
  64         (active_op)->flags = pcmk__clear_flags_as(__func__, __LINE__,       \
  65             LOG_TRACE, "Active operation", (active_op)->op_key,             \
  66             (active_op)->flags, (flags_to_clear), #flags_to_clear);         \
  67     } while (0)
  68 
  69 typedef struct lrm_state_s {
  70     const char *node_name;
  71     void *conn;                 // Reserved for controld_execd_state.c usage
  72     void *remote_ra_data;       // Reserved for controld_remote_ra.c usage
  73 
  74     GHashTable *resource_history;
  75     GHashTable *pending_ops;
  76     GHashTable *deletion_ops;
  77     GHashTable *rsc_info_cache;
  78     GHashTable *metadata_cache; // key = class[:provider]:agent, value = ra_metadata_s
  79 
  80     int num_lrm_register_fails;
  81 } lrm_state_t;
  82 
  83 struct pending_deletion_op_s {
  84     char *rsc;
  85     ha_msg_input_t *input;
  86 };
  87 
  88 /*!
  89  * \brief Check whether this the local IPC connection to the executor
  90  */
  91 gboolean
  92 lrm_state_is_local(lrm_state_t *lrm_state);
  93 
  94 /*!
  95  * \brief Clear all state information from a single state entry.
  96  * \note It sometimes useful to save metadata cache when it won't go stale.
  97  * \note This does not close the executor connection
  98  */
  99 void lrm_state_reset_tables(lrm_state_t * lrm_state, gboolean reset_metadata);
 100 GList *lrm_state_get_list(void);
 101 
 102 /*!
 103  * \brief Initiate internal state tables
 104  */
 105 gboolean lrm_state_init_local(void);
 106 
 107 /*!
 108  * \brief Destroy all state entries and internal state tables
 109  */
 110 void lrm_state_destroy_all(void);
 111 
 112 /*!
 113  * \brief Create executor connection entry
 114  */
 115 lrm_state_t *lrm_state_create(const char *node_name);
 116 
 117 /*!
 118  * \brief Destroy executor connection by node name
 119  */
 120 void lrm_state_destroy(const char *node_name);
 121 
 122 /*!
 123  * \brief Find lrm_state data by node name
 124  */
 125 lrm_state_t *lrm_state_find(const char *node_name);
 126 
 127 /*!
 128  * \brief Either find or create a new entry
 129  */
 130 lrm_state_t *lrm_state_find_or_create(const char *node_name);
 131 
 132 /*!
 133  * The functions below are wrappers for the executor API the the controller
 134  * uses. These wrapper functions allow us to treat the controller's remote
 135  * executor connection resources the same as regular resources. Internally,
 136  * regular resources go to the executor, and remote connection resources are
 137  * handled locally in the controller.
 138  */
 139 void lrm_state_disconnect_only(lrm_state_t * lrm_state);
 140 void lrm_state_disconnect(lrm_state_t * lrm_state);
 141 int lrm_state_ipc_connect(lrm_state_t * lrm_state);
 142 int lrm_state_remote_connect_async(lrm_state_t * lrm_state, const char *server, int port,
 143                                    int timeout);
 144 int lrm_state_is_connected(lrm_state_t * lrm_state);
 145 int lrm_state_poke_connection(lrm_state_t * lrm_state);
 146 
 147 int lrm_state_get_metadata(lrm_state_t * lrm_state,
 148                            const char *class,
 149                            const char *provider,
 150                            const char *agent, char **output, enum lrmd_call_options options);
 151 int lrm_state_cancel(lrm_state_t *lrm_state, const char *rsc_id,
 152                      const char *action, guint interval_ms);
 153 int lrm_state_exec(lrm_state_t *lrm_state, const char *rsc_id,
 154                    const char *action, const char *userdata, guint interval_ms,
 155                    int timeout, /* ms */
 156                    int start_delay,     /* ms */
 157                    lrmd_key_value_t * params);
 158 lrmd_rsc_info_t *lrm_state_get_rsc_info(lrm_state_t * lrm_state,
 159                                         const char *rsc_id, enum lrmd_call_options options);
 160 int lrm_state_register_rsc(lrm_state_t * lrm_state,
 161                            const char *rsc_id,
 162                            const char *class,
 163                            const char *provider, const char *agent, enum lrmd_call_options options);
 164 int lrm_state_unregister_rsc(lrm_state_t * lrm_state,
 165                              const char *rsc_id, enum lrmd_call_options options);
 166 
 167 // Functions used to manage remote executor connection resources
 168 void remote_lrm_op_callback(lrmd_event_data_t * op);
 169 gboolean is_remote_lrmd_ra(const char *agent, const char *provider, const char *id);
 170 lrmd_rsc_info_t *remote_ra_get_rsc_info(lrm_state_t * lrm_state, const char *rsc_id);
 171 int remote_ra_cancel(lrm_state_t *lrm_state, const char *rsc_id,
 172                      const char *action, guint interval_ms);
 173 int remote_ra_exec(lrm_state_t *lrm_state, const char *rsc_id,
 174                    const char *action, const char *userdata, guint interval_ms,
 175                    int timeout, /* ms */
 176                    int start_delay,     /* ms */
 177                    lrmd_key_value_t * params);
 178 void remote_ra_cleanup(lrm_state_t * lrm_state);
 179 void remote_ra_fail(const char *node_name);
 180 void remote_ra_process_pseudo(xmlNode *xml);
 181 gboolean remote_ra_is_in_maintenance(lrm_state_t * lrm_state);
 182 void remote_ra_process_maintenance_nodes(xmlNode *xml);
 183 gboolean remote_ra_controlling_guest(lrm_state_t * lrm_state);
 184 
 185 void process_lrm_event(lrm_state_t *lrm_state, lrmd_event_data_t *op,
 186                        active_op_t *pending, xmlNode *action_xml);
 187 void controld_ack_event_directly(const char *to_host, const char *to_sys,
 188                                  lrmd_rsc_info_t *rsc, lrmd_event_data_t *op,
 189                                  const char *rsc_id);
 190 void controld_rc2event(lrmd_event_data_t *event, int rc);
 191 void controld_trigger_delete_refresh(const char *from_sys, const char *rsc_id);
 192 
 193 #endif

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