|
rpm-build |
3ee90c |
/*
|
|
rpm-build |
3ee90c |
* Copyright 2004-2019 the Pacemaker project contributors
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* The version control history for this file may have further details.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* This source code is licensed under the GNU General Public License version 2
|
|
rpm-build |
3ee90c |
* or later (GPLv2+) WITHOUT ANY WARRANTY.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#include <crm_internal.h>
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#include <regex.h>
|
|
rpm-build |
3ee90c |
#include <sys/param.h>
|
|
rpm-build |
3ee90c |
#include <sys/types.h>
|
|
rpm-build |
3ee90c |
#include <sys/wait.h>
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#include <crm/crm.h>
|
|
rpm-build |
3ee90c |
#include <crm/lrmd.h> // lrmd_event_data_t, lrmd_rsc_info_t, etc.
|
|
rpm-build |
3ee90c |
#include <crm/services.h>
|
|
rpm-build |
3ee90c |
#include <crm/msg_xml.h>
|
|
rpm-build |
3ee90c |
#include <crm/common/xml.h>
|
|
rpm-build |
3ee90c |
#include <crm/pengine/rules.h>
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#include <pacemaker-internal.h>
|
|
rpm-build |
3ee90c |
#include <pacemaker-controld.h>
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#define START_DELAY_THRESHOLD 5 * 60 * 1000
|
|
rpm-build |
3ee90c |
#define MAX_LRM_REG_FAILS 30
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#define s_if_plural(i) (((i) == 1)? "" : "s")
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
struct delete_event_s {
|
|
rpm-build |
3ee90c |
int rc;
|
|
rpm-build |
3ee90c |
const char *rsc;
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state;
|
|
rpm-build |
3ee90c |
};
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean is_rsc_active(lrm_state_t * lrm_state, const char *rsc_id);
|
|
rpm-build |
3ee90c |
static gboolean build_active_RAs(lrm_state_t * lrm_state, xmlNode * rsc_list);
|
|
rpm-build |
3ee90c |
static gboolean stop_recurring_actions(gpointer key, gpointer value, gpointer user_data);
|
|
rpm-build |
3ee90c |
static int delete_rsc_status(lrm_state_t * lrm_state, const char *rsc_id, int call_options,
|
|
rpm-build |
3ee90c |
const char *user_name);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static lrmd_event_data_t *construct_op(lrm_state_t * lrm_state, xmlNode * rsc_op,
|
|
rpm-build |
3ee90c |
const char *rsc_id, const char *operation);
|
|
|
7201e2 |
static void do_lrm_rsc_op(lrm_state_t *lrm_state, lrmd_rsc_info_t *rsc,
|
|
|
7201e2 |
const char *operation, xmlNode *msg);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
void send_direct_ack(const char *to_host, const char *to_sys,
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t * rsc, lrmd_event_data_t * op, const char *rsc_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean lrm_state_verify_stopped(lrm_state_t * lrm_state, enum crmd_fsa_state cur_state,
|
|
rpm-build |
3ee90c |
int log_level);
|
|
rpm-build |
3ee90c |
static int do_update_resource(const char *node_name, lrmd_rsc_info_t * rsc, lrmd_event_data_t * op);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
lrm_connection_destroy(void)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
if (is_set(fsa_input_register, R_LRM_CONNECTED)) {
|
|
rpm-build |
3ee90c |
crm_crit("Connection to executor failed");
|
|
rpm-build |
3ee90c |
register_fsa_input(C_FSA_INTERNAL, I_ERROR, NULL);
|
|
rpm-build |
3ee90c |
clear_bit(fsa_input_register, R_LRM_CONNECTED);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_info("Disconnected from executor");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static char *
|
|
rpm-build |
3ee90c |
make_stop_id(const char *rsc, int call_id)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
return crm_strdup_printf("%s:%d", rsc, call_id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
copy_instance_keys(gpointer key, gpointer value, gpointer user_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
if (strstr(key, CRM_META "_") == NULL) {
|
|
rpm-build |
3ee90c |
g_hash_table_replace(user_data, strdup((const char *)key), strdup((const char *)value));
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
copy_meta_keys(gpointer key, gpointer value, gpointer user_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
if (strstr(key, CRM_META "_") != NULL) {
|
|
rpm-build |
3ee90c |
g_hash_table_replace(user_data, strdup((const char *)key), strdup((const char *)value));
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \internal
|
|
rpm-build |
3ee90c |
* \brief Remove a recurring operation from a resource's history
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in,out] history Resource history to modify
|
|
rpm-build |
3ee90c |
* \param[in] op Operation to remove
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \return TRUE if the operation was found and removed, FALSE otherwise
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
history_remove_recurring_op(rsc_history_t *history, const lrmd_event_data_t *op)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
GList *iter;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
for (iter = history->recurring_op_list; iter != NULL; iter = iter->next) {
|
|
rpm-build |
3ee90c |
lrmd_event_data_t *existing = iter->data;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if ((op->interval_ms == existing->interval_ms)
|
|
rpm-build |
3ee90c |
&& crm_str_eq(op->rsc_id, existing->rsc_id, TRUE)
|
|
rpm-build |
3ee90c |
&& safe_str_eq(op->op_type, existing->op_type)) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
history->recurring_op_list = g_list_delete_link(history->recurring_op_list, iter);
|
|
rpm-build |
3ee90c |
lrmd_free_event(existing);
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \internal
|
|
rpm-build |
3ee90c |
* \brief Free all recurring operations in resource history
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in,out] history Resource history to modify
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
history_free_recurring_ops(rsc_history_t *history)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
GList *iter;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
for (iter = history->recurring_op_list; iter != NULL; iter = iter->next) {
|
|
rpm-build |
3ee90c |
lrmd_free_event(iter->data);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
g_list_free(history->recurring_op_list);
|
|
rpm-build |
3ee90c |
history->recurring_op_list = NULL;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \internal
|
|
rpm-build |
3ee90c |
* \brief Free resource history
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in,out] history Resource history to free
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
void
|
|
rpm-build |
3ee90c |
history_free(gpointer data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
rsc_history_t *history = (rsc_history_t*)data;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (history->stop_params) {
|
|
rpm-build |
3ee90c |
g_hash_table_destroy(history->stop_params);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Don't need to free history->rsc.id because it's set to history->id */
|
|
rpm-build |
3ee90c |
free(history->rsc.type);
|
|
rpm-build |
3ee90c |
free(history->rsc.standard);
|
|
rpm-build |
3ee90c |
free(history->rsc.provider);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
lrmd_free_event(history->failed);
|
|
rpm-build |
3ee90c |
lrmd_free_event(history->last);
|
|
rpm-build |
3ee90c |
free(history->id);
|
|
rpm-build |
3ee90c |
history_free_recurring_ops(history);
|
|
rpm-build |
3ee90c |
free(history);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
update_history_cache(lrm_state_t * lrm_state, lrmd_rsc_info_t * rsc, lrmd_event_data_t * op)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
int target_rc = 0;
|
|
rpm-build |
3ee90c |
rsc_history_t *entry = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->rsc_deleted) {
|
|
rpm-build |
3ee90c |
crm_debug("Purged history for '%s' after %s", op->rsc_id, op->op_type);
|
|
rpm-build |
3ee90c |
delete_rsc_status(lrm_state, op->rsc_id, cib_quorum_override, NULL);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_eq(op->op_type, RSC_NOTIFY)) {
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("Updating history for '%s' with %s op", op->rsc_id, op->op_type);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
entry = g_hash_table_lookup(lrm_state->resource_history, op->rsc_id);
|
|
rpm-build |
3ee90c |
if (entry == NULL && rsc) {
|
|
rpm-build |
3ee90c |
entry = calloc(1, sizeof(rsc_history_t));
|
|
rpm-build |
3ee90c |
entry->id = strdup(op->rsc_id);
|
|
rpm-build |
3ee90c |
g_hash_table_insert(lrm_state->resource_history, entry->id, entry);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
entry->rsc.id = entry->id;
|
|
rpm-build |
3ee90c |
entry->rsc.type = strdup(rsc->type);
|
|
rpm-build |
3ee90c |
entry->rsc.standard = strdup(rsc->standard);
|
|
rpm-build |
3ee90c |
if (rsc->provider) {
|
|
rpm-build |
3ee90c |
entry->rsc.provider = strdup(rsc->provider);
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
entry->rsc.provider = NULL;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (entry == NULL) {
|
|
rpm-build |
3ee90c |
crm_info("Resource %s no longer exists, not updating cache", op->rsc_id);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
entry->last_callid = op->call_id;
|
|
rpm-build |
3ee90c |
target_rc = rsc_op_expected_rc(op);
|
|
rpm-build |
3ee90c |
if (op->op_status == PCMK_LRM_OP_CANCELLED) {
|
|
rpm-build |
3ee90c |
if (op->interval_ms > 0) {
|
|
rpm-build |
3ee90c |
crm_trace("Removing cancelled recurring op: " CRM_OP_FMT,
|
|
rpm-build |
3ee90c |
op->rsc_id, op->op_type, op->interval_ms);
|
|
rpm-build |
3ee90c |
history_remove_recurring_op(entry, op);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_trace("Skipping " CRM_OP_FMT " rc=%d, status=%d",
|
|
rpm-build |
3ee90c |
op->rsc_id, op->op_type, op->interval_ms, op->rc,
|
|
rpm-build |
3ee90c |
op->op_status);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (did_rsc_op_fail(op, target_rc)) {
|
|
rpm-build |
3ee90c |
/* Store failed monitors here, otherwise the block below will cause them
|
|
rpm-build |
3ee90c |
* to be forgotten when a stop happens.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
if (entry->failed) {
|
|
rpm-build |
3ee90c |
lrmd_free_event(entry->failed);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
entry->failed = lrmd_copy_event(op);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (op->interval_ms == 0) {
|
|
rpm-build |
3ee90c |
if (entry->last) {
|
|
rpm-build |
3ee90c |
lrmd_free_event(entry->last);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
entry->last = lrmd_copy_event(op);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->params &&
|
|
rpm-build |
3ee90c |
(safe_str_eq(CRMD_ACTION_START, op->op_type) ||
|
|
rpm-build |
3ee90c |
safe_str_eq("reload", op->op_type) ||
|
|
rpm-build |
3ee90c |
safe_str_eq(CRMD_ACTION_STATUS, op->op_type))) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (entry->stop_params) {
|
|
rpm-build |
3ee90c |
g_hash_table_destroy(entry->stop_params);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
entry->stop_params = crm_str_table_new();
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
g_hash_table_foreach(op->params, copy_instance_keys, entry->stop_params);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->interval_ms > 0) {
|
|
rpm-build |
3ee90c |
/* Ensure there are no duplicates */
|
|
rpm-build |
3ee90c |
history_remove_recurring_op(entry, op);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("Adding recurring op: " CRM_OP_FMT,
|
|
rpm-build |
3ee90c |
op->rsc_id, op->op_type, op->interval_ms);
|
|
rpm-build |
3ee90c |
entry->recurring_op_list = g_list_prepend(entry->recurring_op_list, lrmd_copy_event(op));
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (entry->recurring_op_list && safe_str_eq(op->op_type, RSC_STATUS) == FALSE) {
|
|
rpm-build |
3ee90c |
crm_trace("Dropping %d recurring ops because of: " CRM_OP_FMT,
|
|
rpm-build |
3ee90c |
g_list_length(entry->recurring_op_list), op->rsc_id,
|
|
rpm-build |
3ee90c |
op->op_type, op->interval_ms);
|
|
rpm-build |
3ee90c |
history_free_recurring_ops(entry);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \internal
|
|
rpm-build |
3ee90c |
* \brief Send a direct OK ack for a resource task
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in] lrm_state LRM connection
|
|
rpm-build |
3ee90c |
* \param[in] input Input message being ack'ed
|
|
rpm-build |
3ee90c |
* \param[in] rsc_id ID of affected resource
|
|
rpm-build |
3ee90c |
* \param[in] rsc Affected resource (if available)
|
|
rpm-build |
3ee90c |
* \param[in] task Operation task being ack'ed
|
|
rpm-build |
3ee90c |
* \param[in] ack_host Name of host to send ack to
|
|
rpm-build |
3ee90c |
* \param[in] ack_sys IPC system name to ack
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
send_task_ok_ack(lrm_state_t *lrm_state, ha_msg_input_t *input,
|
|
rpm-build |
3ee90c |
const char *rsc_id, lrmd_rsc_info_t *rsc, const char *task,
|
|
rpm-build |
3ee90c |
const char *ack_host, const char *ack_sys)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
lrmd_event_data_t *op = construct_op(lrm_state, input->xml, rsc_id, task);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op->rc = PCMK_OCF_OK;
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_DONE;
|
|
rpm-build |
3ee90c |
send_direct_ack(ack_host, ack_sys, rsc, op, rsc_id);
|
|
rpm-build |
3ee90c |
lrmd_free_event(op);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static inline const char *
|
|
rpm-build |
3ee90c |
op_node_name(lrmd_event_data_t *op)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
return op->remote_nodename? op->remote_nodename : fsa_our_uname;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
void
|
|
rpm-build |
3ee90c |
lrm_op_callback(lrmd_event_data_t * op)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
CRM_CHECK(op != NULL, return);
|
|
rpm-build |
3ee90c |
switch (op->type) {
|
|
rpm-build |
3ee90c |
case lrmd_event_disconnect:
|
|
rpm-build |
3ee90c |
if (op->remote_nodename == NULL) {
|
|
rpm-build |
3ee90c |
/* If this is the local executor IPC connection, set the right
|
|
rpm-build |
3ee90c |
* bits in the controller when the connection goes down.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
lrm_connection_destroy();
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
case lrmd_event_exec_complete:
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state = lrm_state_find(op_node_name(op));
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_ASSERT(lrm_state != NULL);
|
|
rpm-build |
3ee90c |
process_lrm_event(lrm_state, op, NULL, NULL);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
default:
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* A_LRM_CONNECT */
|
|
rpm-build |
3ee90c |
void
|
|
rpm-build |
3ee90c |
do_lrm_control(long long action,
|
|
rpm-build |
3ee90c |
enum crmd_fsa_cause cause,
|
|
rpm-build |
3ee90c |
enum crmd_fsa_state cur_state,
|
|
rpm-build |
3ee90c |
enum crmd_fsa_input current_input, fsa_data_t * msg_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
/* This only pertains to local executor connections. Remote connections are
|
|
rpm-build |
3ee90c |
* handled as resources within the scheduler. Connecting and disconnecting
|
|
rpm-build |
3ee90c |
* from remote executor instances is handled differently.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if(fsa_our_uname == NULL) {
|
|
rpm-build |
3ee90c |
return; /* Nothing to do */
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
lrm_state = lrm_state_find_or_create(fsa_our_uname);
|
|
rpm-build |
3ee90c |
if (lrm_state == NULL) {
|
|
rpm-build |
3ee90c |
register_fsa_error(C_FSA_INTERNAL, I_ERROR, NULL);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (action & A_LRM_DISCONNECT) {
|
|
rpm-build |
3ee90c |
if (lrm_state_verify_stopped(lrm_state, cur_state, LOG_INFO) == FALSE) {
|
|
rpm-build |
3ee90c |
if (action == A_LRM_DISCONNECT) {
|
|
rpm-build |
3ee90c |
crmd_fsa_stall(FALSE);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
clear_bit(fsa_input_register, R_LRM_CONNECTED);
|
|
rpm-build |
3ee90c |
crm_info("Disconnecting from the executor");
|
|
rpm-build |
3ee90c |
lrm_state_disconnect(lrm_state);
|
|
rpm-build |
3ee90c |
lrm_state_reset_tables(lrm_state, FALSE);
|
|
rpm-build |
3ee90c |
crm_notice("Disconnected from the executor");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (action & A_LRM_CONNECT) {
|
|
rpm-build |
3ee90c |
int ret = pcmk_ok;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("Connecting to the executor");
|
|
rpm-build |
3ee90c |
ret = lrm_state_ipc_connect(lrm_state);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (ret != pcmk_ok) {
|
|
rpm-build |
3ee90c |
if (lrm_state->num_lrm_register_fails < MAX_LRM_REG_FAILS) {
|
|
rpm-build |
3ee90c |
crm_warn("Failed to connect to the executor %d time%s (%d max)",
|
|
rpm-build |
3ee90c |
lrm_state->num_lrm_register_fails,
|
|
rpm-build |
3ee90c |
s_if_plural(lrm_state->num_lrm_register_fails),
|
|
rpm-build |
3ee90c |
MAX_LRM_REG_FAILS);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
controld_start_timer(wait_timer);
|
|
rpm-build |
3ee90c |
crmd_fsa_stall(FALSE);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (ret != pcmk_ok) {
|
|
rpm-build |
3ee90c |
crm_err("Failed to connect to the executor the max allowed %d time%s",
|
|
rpm-build |
3ee90c |
lrm_state->num_lrm_register_fails,
|
|
rpm-build |
3ee90c |
s_if_plural(lrm_state->num_lrm_register_fails));
|
|
rpm-build |
3ee90c |
register_fsa_error(C_FSA_INTERNAL, I_ERROR, NULL);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
set_bit(fsa_input_register, R_LRM_CONNECTED);
|
|
rpm-build |
3ee90c |
crm_info("Connection to the executor established");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (action & ~(A_LRM_CONNECT | A_LRM_DISCONNECT)) {
|
|
rpm-build |
3ee90c |
crm_err("Unexpected action %s in %s", fsa_action2string(action), __FUNCTION__);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
lrm_state_verify_stopped(lrm_state_t * lrm_state, enum crmd_fsa_state cur_state, int log_level)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
int counter = 0;
|
|
rpm-build |
3ee90c |
gboolean rc = TRUE;
|
|
rpm-build |
3ee90c |
const char *when = "lrm disconnect";
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
GHashTableIter gIter;
|
|
rpm-build |
3ee90c |
const char *key = NULL;
|
|
rpm-build |
3ee90c |
rsc_history_t *entry = NULL;
|
|
|
2e9006 |
active_op_t *pending = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("Checking for active resources before exit");
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (cur_state == S_TERMINATE) {
|
|
rpm-build |
3ee90c |
log_level = LOG_ERR;
|
|
rpm-build |
3ee90c |
when = "shutdown";
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (is_set(fsa_input_register, R_SHUTDOWN)) {
|
|
rpm-build |
3ee90c |
when = "shutdown... waiting";
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (lrm_state->pending_ops && lrm_state_is_connected(lrm_state) == TRUE) {
|
|
rpm-build |
3ee90c |
guint removed = g_hash_table_foreach_remove(
|
|
rpm-build |
3ee90c |
lrm_state->pending_ops, stop_recurring_actions, lrm_state);
|
|
rpm-build |
3ee90c |
guint nremaining = g_hash_table_size(lrm_state->pending_ops);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (removed || nremaining) {
|
|
rpm-build |
3ee90c |
crm_notice("Stopped %u recurring operation%s at %s (%u remaining)",
|
|
rpm-build |
3ee90c |
removed, s_if_plural(removed), when, nremaining);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (lrm_state->pending_ops) {
|
|
rpm-build |
3ee90c |
g_hash_table_iter_init(&gIter, lrm_state->pending_ops);
|
|
rpm-build |
3ee90c |
while (g_hash_table_iter_next(&gIter, NULL, (void **)&pending)) {
|
|
rpm-build |
3ee90c |
/* Ignore recurring actions in the shutdown calculations */
|
|
rpm-build |
3ee90c |
if (pending->interval_ms == 0) {
|
|
rpm-build |
3ee90c |
counter++;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (counter > 0) {
|
|
rpm-build |
3ee90c |
do_crm_log(log_level, "%d pending executor operation%s at %s",
|
|
rpm-build |
3ee90c |
counter, s_if_plural(counter), when);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (cur_state == S_TERMINATE || !is_set(fsa_input_register, R_SENT_RSC_STOP)) {
|
|
rpm-build |
3ee90c |
g_hash_table_iter_init(&gIter, lrm_state->pending_ops);
|
|
rpm-build |
3ee90c |
while (g_hash_table_iter_next(&gIter, (gpointer*)&key, (gpointer*)&pending)) {
|
|
rpm-build |
3ee90c |
do_crm_log(log_level, "Pending action: %s (%s)", key, pending->op_key);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
rc = FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return rc;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (lrm_state->resource_history == NULL) {
|
|
rpm-build |
3ee90c |
return rc;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (is_set(fsa_input_register, R_SHUTDOWN)) {
|
|
rpm-build |
3ee90c |
/* At this point we're not waiting, we're just shutting down */
|
|
rpm-build |
3ee90c |
when = "shutdown";
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
counter = 0;
|
|
rpm-build |
3ee90c |
g_hash_table_iter_init(&gIter, lrm_state->resource_history);
|
|
rpm-build |
3ee90c |
while (g_hash_table_iter_next(&gIter, NULL, (gpointer*)&entry)) {
|
|
rpm-build |
3ee90c |
if (is_rsc_active(lrm_state, entry->id) == FALSE) {
|
|
rpm-build |
3ee90c |
continue;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
counter++;
|
|
rpm-build |
3ee90c |
if (log_level == LOG_ERR) {
|
|
rpm-build |
3ee90c |
crm_info("Found %s active at %s", entry->id, when);
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_trace("Found %s active at %s", entry->id, when);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
if (lrm_state->pending_ops) {
|
|
rpm-build |
3ee90c |
GHashTableIter hIter;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
g_hash_table_iter_init(&hIter, lrm_state->pending_ops);
|
|
rpm-build |
3ee90c |
while (g_hash_table_iter_next(&hIter, (gpointer*)&key, (gpointer*)&pending)) {
|
|
rpm-build |
3ee90c |
if (crm_str_eq(entry->id, pending->rsc_id, TRUE)) {
|
|
rpm-build |
3ee90c |
crm_notice("%sction %s (%s) incomplete at %s",
|
|
rpm-build |
3ee90c |
pending->interval_ms == 0 ? "A" : "Recurring a",
|
|
rpm-build |
3ee90c |
key, pending->op_key, when);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (counter) {
|
|
rpm-build |
3ee90c |
crm_err("%d resource%s active at %s",
|
|
rpm-build |
3ee90c |
counter, (counter == 1)? " was" : "s were", when);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return rc;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static char *
|
|
rpm-build |
3ee90c |
build_parameter_list(const lrmd_event_data_t *op,
|
|
rpm-build |
3ee90c |
const struct ra_metadata_s *metadata,
|
|
rpm-build |
3ee90c |
xmlNode *result, enum ra_param_flags_e param_type,
|
|
rpm-build |
3ee90c |
bool invert_for_xml)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
int len = 0;
|
|
rpm-build |
3ee90c |
int max = 0;
|
|
rpm-build |
3ee90c |
char *list = NULL;
|
|
rpm-build |
3ee90c |
GList *iter = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Newer resource agents support the "private" parameter attribute to
|
|
rpm-build |
3ee90c |
* indicate sensitive parameters. For backward compatibility with older
|
|
rpm-build |
3ee90c |
* agents, this list is used if the agent doesn't specify any as "private".
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
const char *secure_terms[] = {
|
|
rpm-build |
3ee90c |
"password",
|
|
rpm-build |
3ee90c |
"passwd",
|
|
rpm-build |
3ee90c |
"user",
|
|
rpm-build |
3ee90c |
};
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (is_not_set(metadata->ra_flags, ra_uses_private)
|
|
rpm-build |
3ee90c |
&& (param_type == ra_param_private)) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
max = DIMOF(secure_terms);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
for (iter = metadata->ra_params; iter != NULL; iter = iter->next) {
|
|
rpm-build |
3ee90c |
struct ra_param_s *param = (struct ra_param_s *) iter->data;
|
|
rpm-build |
3ee90c |
bool accept = FALSE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (is_set(param->rap_flags, param_type)) {
|
|
rpm-build |
3ee90c |
accept = TRUE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (max) {
|
|
rpm-build |
3ee90c |
for (int lpc = 0; lpc < max; lpc++) {
|
|
rpm-build |
3ee90c |
if (safe_str_eq(secure_terms[lpc], param->rap_name)) {
|
|
rpm-build |
3ee90c |
accept = TRUE;
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (accept) {
|
|
rpm-build |
3ee90c |
int start = len;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("Attr %s is %s", param->rap_name, ra_param_flag2text(param_type));
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
len += strlen(param->rap_name) + 2; // include spaces around
|
|
rpm-build |
3ee90c |
list = realloc_safe(list, len + 1); // include null terminator
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// spaces before and after make parsing simpler
|
|
rpm-build |
3ee90c |
sprintf(list + start, " %s ", param->rap_name);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_trace("Rejecting %s for %s", param->rap_name, ra_param_flag2text(param_type));
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (result && (invert_for_xml? !accept : accept)) {
|
|
rpm-build |
3ee90c |
const char *v = g_hash_table_lookup(op->params, param->rap_name);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (v != NULL) {
|
|
rpm-build |
3ee90c |
crm_trace("Adding attr %s=%s to the xml result", param->rap_name, v);
|
|
rpm-build |
3ee90c |
crm_xml_add(result, param->rap_name, v);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return list;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
append_restart_list(lrmd_event_data_t *op, struct ra_metadata_s *metadata,
|
|
rpm-build |
3ee90c |
xmlNode *update, const char *version)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
char *list = NULL;
|
|
rpm-build |
3ee90c |
char *digest = NULL;
|
|
rpm-build |
3ee90c |
xmlNode *restart = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_LOG_ASSERT(op->params != NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->interval_ms > 0) {
|
|
rpm-build |
3ee90c |
/* monitors are not reloadable */
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (is_set(metadata->ra_flags, ra_supports_reload)) {
|
|
rpm-build |
3ee90c |
restart = create_xml_node(NULL, XML_TAG_PARAMS);
|
|
rpm-build |
3ee90c |
/* Add any parameters with unique="1" to the "op-force-restart" list.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* (Currently, we abuse "unique=0" to indicate reloadability. This is
|
|
rpm-build |
3ee90c |
* nonstandard and should eventually be replaced once the OCF standard
|
|
rpm-build |
3ee90c |
* is updated with something better.)
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
list = build_parameter_list(op, metadata, restart, ra_param_unique,
|
|
rpm-build |
3ee90c |
FALSE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
/* Resource does not support reloads */
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
digest = calculate_operation_digest(restart, version);
|
|
rpm-build |
3ee90c |
/* Add "op-force-restart" and "op-restart-digest" to indicate the resource supports reload,
|
|
rpm-build |
3ee90c |
* no matter if it actually supports any parameters with unique="1"). */
|
|
rpm-build |
3ee90c |
crm_xml_add(update, XML_LRM_ATTR_OP_RESTART, list? list: "");
|
|
rpm-build |
3ee90c |
crm_xml_add(update, XML_LRM_ATTR_RESTART_DIGEST, digest);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("%s: %s, %s", op->rsc_id, digest, list);
|
|
rpm-build |
3ee90c |
crm_log_xml_trace(restart, "restart digest source");
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
free_xml(restart);
|
|
rpm-build |
3ee90c |
free(digest);
|
|
rpm-build |
3ee90c |
free(list);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
append_secure_list(lrmd_event_data_t *op, struct ra_metadata_s *metadata,
|
|
rpm-build |
3ee90c |
xmlNode *update, const char *version)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
char *list = NULL;
|
|
rpm-build |
3ee90c |
char *digest = NULL;
|
|
rpm-build |
3ee90c |
xmlNode *secure = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_LOG_ASSERT(op->params != NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*
|
|
rpm-build |
3ee90c |
* To keep XML_LRM_ATTR_OP_SECURE short, we want it to contain the
|
|
rpm-build |
3ee90c |
* secure parameters but XML_LRM_ATTR_SECURE_DIGEST to be based on
|
|
rpm-build |
3ee90c |
* the insecure ones
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
secure = create_xml_node(NULL, XML_TAG_PARAMS);
|
|
rpm-build |
3ee90c |
list = build_parameter_list(op, metadata, secure, ra_param_private, TRUE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (list != NULL) {
|
|
rpm-build |
3ee90c |
digest = calculate_operation_digest(secure, version);
|
|
rpm-build |
3ee90c |
crm_xml_add(update, XML_LRM_ATTR_OP_SECURE, list);
|
|
rpm-build |
3ee90c |
crm_xml_add(update, XML_LRM_ATTR_SECURE_DIGEST, digest);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("%s: %s, %s", op->rsc_id, digest, list);
|
|
rpm-build |
3ee90c |
crm_log_xml_trace(secure, "secure digest source");
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_trace("%s: no secure parameters", op->rsc_id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
free_xml(secure);
|
|
rpm-build |
3ee90c |
free(digest);
|
|
rpm-build |
3ee90c |
free(list);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
build_operation_update(xmlNode * parent, lrmd_rsc_info_t * rsc, lrmd_event_data_t * op,
|
|
rpm-build |
3ee90c |
const char *node_name, const char *src)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
int target_rc = 0;
|
|
rpm-build |
3ee90c |
xmlNode *xml_op = NULL;
|
|
rpm-build |
3ee90c |
struct ra_metadata_s *metadata = NULL;
|
|
rpm-build |
3ee90c |
const char *caller_version = NULL;
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op == NULL) {
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
target_rc = rsc_op_expected_rc(op);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* there is a small risk in formerly mixed clusters that it will
|
|
rpm-build |
3ee90c |
* be sub-optimal.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* however with our upgrade policy, the update we send should
|
|
rpm-build |
3ee90c |
* still be completely supported anyway
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
caller_version = g_hash_table_lookup(op->params, XML_ATTR_CRM_VERSION);
|
|
rpm-build |
3ee90c |
CRM_LOG_ASSERT(caller_version != NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if(caller_version == NULL) {
|
|
rpm-build |
3ee90c |
caller_version = CRM_FEATURE_SET;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("Building %s operation update with originator version: %s", op->rsc_id, caller_version);
|
|
rpm-build |
3ee90c |
xml_op = pcmk__create_history_xml(parent, op, caller_version, target_rc,
|
|
rpm-build |
3ee90c |
fsa_our_uname, src, LOG_DEBUG);
|
|
rpm-build |
3ee90c |
if (xml_op == NULL) {
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if ((rsc == NULL) || (op->params == NULL)
|
|
rpm-build |
3ee90c |
|| !crm_op_needs_metadata(rsc->standard, op->op_type)) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("No digests needed for %s action on %s (params=%p rsc=%p)",
|
|
rpm-build |
3ee90c |
op->op_type, op->rsc_id, op->params, rsc);
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
lrm_state = lrm_state_find(node_name);
|
|
rpm-build |
3ee90c |
if (lrm_state == NULL) {
|
|
rpm-build |
3ee90c |
crm_warn("Cannot calculate digests for operation " CRM_OP_FMT
|
|
rpm-build |
3ee90c |
" because we have no connection to executor for %s",
|
|
rpm-build |
3ee90c |
op->rsc_id, op->op_type, op->interval_ms, node_name);
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
metadata = metadata_cache_get(lrm_state->metadata_cache, rsc);
|
|
rpm-build |
3ee90c |
if (metadata == NULL) {
|
|
rpm-build |
3ee90c |
/* For now, we always collect resource agent meta-data via a local,
|
|
rpm-build |
3ee90c |
* synchronous, direct execution of the agent. This has multiple issues:
|
|
rpm-build |
3ee90c |
* the executor should execute agents, not the controller; meta-data for
|
|
rpm-build |
3ee90c |
* Pacemaker Remote nodes should be collected on those nodes, not
|
|
rpm-build |
3ee90c |
* locally; and the meta-data call shouldn't eat into the timeout of the
|
|
rpm-build |
3ee90c |
* real action being performed.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* These issues are planned to be addressed by having the scheduler
|
|
rpm-build |
3ee90c |
* schedule a meta-data cache check at the beginning of each transition.
|
|
rpm-build |
3ee90c |
* Once that is working, this block will only be a fallback in case the
|
|
rpm-build |
3ee90c |
* initial collection fails.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
char *metadata_str = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
int rc = lrm_state_get_metadata(lrm_state, rsc->standard,
|
|
rpm-build |
3ee90c |
rsc->provider, rsc->type,
|
|
rpm-build |
3ee90c |
&metadata_str, 0);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (rc != pcmk_ok) {
|
|
rpm-build |
3ee90c |
crm_warn("Failed to get metadata for %s (%s:%s:%s)",
|
|
rpm-build |
3ee90c |
rsc->id, rsc->standard, rsc->provider, rsc->type);
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
metadata = metadata_cache_update(lrm_state->metadata_cache, rsc,
|
|
rpm-build |
3ee90c |
metadata_str);
|
|
rpm-build |
3ee90c |
free(metadata_str);
|
|
rpm-build |
3ee90c |
if (metadata == NULL) {
|
|
rpm-build |
3ee90c |
crm_warn("Failed to update metadata for %s (%s:%s:%s)",
|
|
rpm-build |
3ee90c |
rsc->id, rsc->standard, rsc->provider, rsc->type);
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#if ENABLE_VERSIONED_ATTRS
|
|
rpm-build |
3ee90c |
crm_xml_add(xml_op, XML_ATTR_RA_VERSION, metadata->ra_version);
|
|
rpm-build |
3ee90c |
#endif
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("Including additional digests for %s::%s:%s", rsc->standard, rsc->provider, rsc->type);
|
|
rpm-build |
3ee90c |
append_restart_list(op, metadata, xml_op, caller_version);
|
|
rpm-build |
3ee90c |
append_secure_list(op, metadata, xml_op, caller_version);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
is_rsc_active(lrm_state_t * lrm_state, const char *rsc_id)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
rsc_history_t *entry = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
entry = g_hash_table_lookup(lrm_state->resource_history, rsc_id);
|
|
rpm-build |
3ee90c |
if (entry == NULL || entry->last == NULL) {
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("Processing %s: %s.%d=%d", rsc_id, entry->last->op_type,
|
|
rpm-build |
3ee90c |
entry->last->interval_ms, entry->last->rc);
|
|
rpm-build |
3ee90c |
if (entry->last->rc == PCMK_OCF_OK && safe_str_eq(entry->last->op_type, CRMD_ACTION_STOP)) {
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (entry->last->rc == PCMK_OCF_OK
|
|
rpm-build |
3ee90c |
&& safe_str_eq(entry->last->op_type, CRMD_ACTION_MIGRATE)) {
|
|
rpm-build |
3ee90c |
/* a stricter check is too complex...
|
|
rpm-build |
3ee90c |
* leave that to the PE
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (entry->last->rc == PCMK_OCF_NOT_RUNNING) {
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if ((entry->last->interval_ms == 0)
|
|
rpm-build |
3ee90c |
&& (entry->last->rc == PCMK_OCF_NOT_CONFIGURED)) {
|
|
rpm-build |
3ee90c |
/* Badly configured resources can't be reliably stopped */
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
build_active_RAs(lrm_state_t * lrm_state, xmlNode * rsc_list)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
GHashTableIter iter;
|
|
rpm-build |
3ee90c |
rsc_history_t *entry = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
g_hash_table_iter_init(&iter, lrm_state->resource_history);
|
|
rpm-build |
3ee90c |
while (g_hash_table_iter_next(&iter, NULL, (void **)&entry)) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
GList *gIter = NULL;
|
|
rpm-build |
3ee90c |
xmlNode *xml_rsc = create_xml_node(rsc_list, XML_LRM_TAG_RESOURCE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_xml_add(xml_rsc, XML_ATTR_ID, entry->id);
|
|
rpm-build |
3ee90c |
crm_xml_add(xml_rsc, XML_ATTR_TYPE, entry->rsc.type);
|
|
rpm-build |
3ee90c |
crm_xml_add(xml_rsc, XML_AGENT_ATTR_CLASS, entry->rsc.standard);
|
|
rpm-build |
3ee90c |
crm_xml_add(xml_rsc, XML_AGENT_ATTR_PROVIDER, entry->rsc.provider);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (entry->last && entry->last->params) {
|
|
rpm-build |
3ee90c |
const char *container = g_hash_table_lookup(entry->last->params, CRM_META"_"XML_RSC_ATTR_CONTAINER);
|
|
rpm-build |
3ee90c |
if (container) {
|
|
rpm-build |
3ee90c |
crm_trace("Resource %s is a part of container resource %s", entry->id, container);
|
|
rpm-build |
3ee90c |
crm_xml_add(xml_rsc, XML_RSC_ATTR_CONTAINER, container);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
build_operation_update(xml_rsc, &(entry->rsc), entry->failed, lrm_state->node_name, __FUNCTION__);
|
|
rpm-build |
3ee90c |
build_operation_update(xml_rsc, &(entry->rsc), entry->last, lrm_state->node_name, __FUNCTION__);
|
|
rpm-build |
3ee90c |
for (gIter = entry->recurring_op_list; gIter != NULL; gIter = gIter->next) {
|
|
rpm-build |
3ee90c |
build_operation_update(xml_rsc, &(entry->rsc), gIter->data, lrm_state->node_name, __FUNCTION__);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static xmlNode *
|
|
rpm-build |
3ee90c |
do_lrm_query_internal(lrm_state_t *lrm_state, int update_flags)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
xmlNode *xml_state = NULL;
|
|
rpm-build |
3ee90c |
xmlNode *xml_data = NULL;
|
|
rpm-build |
3ee90c |
xmlNode *rsc_list = NULL;
|
|
rpm-build |
3ee90c |
crm_node_t *peer = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
peer = crm_get_peer_full(0, lrm_state->node_name, CRM_GET_PEER_ANY);
|
|
rpm-build |
3ee90c |
CRM_CHECK(peer != NULL, return NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
xml_state = create_node_state_update(peer, update_flags, NULL,
|
|
rpm-build |
3ee90c |
__FUNCTION__);
|
|
rpm-build |
3ee90c |
if (xml_state == NULL) {
|
|
rpm-build |
3ee90c |
return NULL;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
xml_data = create_xml_node(xml_state, XML_CIB_TAG_LRM);
|
|
rpm-build |
3ee90c |
crm_xml_add(xml_data, XML_ATTR_ID, peer->uuid);
|
|
rpm-build |
3ee90c |
rsc_list = create_xml_node(xml_data, XML_LRM_TAG_RESOURCES);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Build a list of active (not always running) resources */
|
|
rpm-build |
3ee90c |
build_active_RAs(lrm_state, rsc_list);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_log_xml_trace(xml_state, "Current executor state");
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return xml_state;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
xmlNode *
|
|
rpm-build |
3ee90c |
do_lrm_query(gboolean is_replace, const char *node_name)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state = lrm_state_find(node_name);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (!lrm_state) {
|
|
rpm-build |
3ee90c |
crm_err("Could not find executor state for node %s", node_name);
|
|
rpm-build |
3ee90c |
return NULL;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return do_lrm_query_internal(lrm_state,
|
|
rpm-build |
3ee90c |
node_update_cluster|node_update_peer);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
notify_deleted(lrm_state_t * lrm_state, ha_msg_input_t * input, const char *rsc_id, int rc)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
lrmd_event_data_t *op = NULL;
|
|
rpm-build |
3ee90c |
const char *from_sys = crm_element_value(input->msg, F_CRM_SYS_FROM);
|
|
rpm-build |
3ee90c |
const char *from_host = crm_element_value(input->msg, F_CRM_HOST_FROM);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_info("Notifying %s on %s that %s was%s deleted",
|
|
rpm-build |
3ee90c |
from_sys, (from_host? from_host : "localhost"), rsc_id,
|
|
rpm-build |
3ee90c |
((rc == pcmk_ok)? "" : " not"));
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op = construct_op(lrm_state, input->xml, rsc_id, CRMD_ACTION_DELETE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (rc == pcmk_ok) {
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_DONE;
|
|
rpm-build |
3ee90c |
op->rc = PCMK_OCF_OK;
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_ERROR;
|
|
rpm-build |
3ee90c |
op->rc = PCMK_OCF_UNKNOWN_ERROR;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
send_direct_ack(from_host, from_sys, NULL, op, rsc_id);
|
|
rpm-build |
3ee90c |
lrmd_free_event(op);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_neq(from_sys, CRM_SYSTEM_TENGINE)) {
|
|
rpm-build |
3ee90c |
/* this isn't expected - trigger a new transition */
|
|
rpm-build |
3ee90c |
time_t now = time(NULL);
|
|
rpm-build |
3ee90c |
char *now_s = crm_itoa(now);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("Triggering a refresh after %s deleted %s from the executor",
|
|
rpm-build |
3ee90c |
from_sys, rsc_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
update_attr_delegate(fsa_cib_conn, cib_none, XML_CIB_TAG_CRMCONFIG, NULL, NULL, NULL, NULL,
|
|
rpm-build |
3ee90c |
"last-lrm-refresh", now_s, FALSE, NULL, NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
free(now_s);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
lrm_remove_deleted_rsc(gpointer key, gpointer value, gpointer user_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
struct delete_event_s *event = user_data;
|
|
rpm-build |
3ee90c |
struct pending_deletion_op_s *op = value;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (crm_str_eq(event->rsc, op->rsc, TRUE)) {
|
|
rpm-build |
3ee90c |
notify_deleted(event->lrm_state, op->input, event->rsc, event->rc);
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
lrm_remove_deleted_op(gpointer key, gpointer value, gpointer user_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
const char *rsc = user_data;
|
|
|
2e9006 |
active_op_t *pending = value;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (crm_str_eq(rsc, pending->rsc_id, TRUE)) {
|
|
rpm-build |
3ee90c |
crm_info("Removing op %s:%d for deleted resource %s",
|
|
rpm-build |
3ee90c |
pending->op_key, pending->call_id, rsc);
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*
|
|
rpm-build |
3ee90c |
* Remove the rsc from the CIB
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* Avoids refreshing the entire LRM section of this host
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
#define RSC_TEMPLATE "//"XML_CIB_TAG_STATE"[@uname='%s']//"XML_LRM_TAG_RESOURCE"[@id='%s']"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static int
|
|
rpm-build |
3ee90c |
delete_rsc_status(lrm_state_t * lrm_state, const char *rsc_id, int call_options,
|
|
rpm-build |
3ee90c |
const char *user_name)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
char *rsc_xpath = NULL;
|
|
rpm-build |
3ee90c |
int rc = pcmk_ok;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(rsc_id != NULL, return -ENXIO);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
rsc_xpath = crm_strdup_printf(RSC_TEMPLATE, lrm_state->node_name, rsc_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
rc = cib_internal_op(fsa_cib_conn, CIB_OP_DELETE, NULL, rsc_xpath,
|
|
rpm-build |
3ee90c |
NULL, NULL, call_options | cib_xpath, user_name);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
free(rsc_xpath);
|
|
rpm-build |
3ee90c |
return rc;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
delete_rsc_entry(lrm_state_t * lrm_state, ha_msg_input_t * input, const char *rsc_id,
|
|
rpm-build |
3ee90c |
GHashTableIter * rsc_gIter, int rc, const char *user_name)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
struct delete_event_s event;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(rsc_id != NULL, return);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (rc == pcmk_ok) {
|
|
rpm-build |
3ee90c |
char *rsc_id_copy = strdup(rsc_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (rsc_gIter)
|
|
rpm-build |
3ee90c |
g_hash_table_iter_remove(rsc_gIter);
|
|
rpm-build |
3ee90c |
else
|
|
rpm-build |
3ee90c |
g_hash_table_remove(lrm_state->resource_history, rsc_id_copy);
|
|
rpm-build |
3ee90c |
crm_debug("sync: Sending delete op for %s", rsc_id_copy);
|
|
rpm-build |
3ee90c |
delete_rsc_status(lrm_state, rsc_id_copy, cib_quorum_override, user_name);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
g_hash_table_foreach_remove(lrm_state->pending_ops, lrm_remove_deleted_op, rsc_id_copy);
|
|
rpm-build |
3ee90c |
free(rsc_id_copy);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (input) {
|
|
rpm-build |
3ee90c |
notify_deleted(lrm_state, input, rsc_id, rc);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
event.rc = rc;
|
|
rpm-build |
3ee90c |
event.rsc = rsc_id;
|
|
rpm-build |
3ee90c |
event.lrm_state = lrm_state;
|
|
rpm-build |
3ee90c |
g_hash_table_foreach_remove(lrm_state->deletion_ops, lrm_remove_deleted_rsc, &event);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \internal
|
|
rpm-build |
3ee90c |
* \brief Erase an LRM history entry from the CIB, given the operation data
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in] lrm_state LRM state of the desired node
|
|
rpm-build |
3ee90c |
* \param[in] op Operation whose history should be deleted
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
erase_lrm_history_by_op(lrm_state_t *lrm_state, lrmd_event_data_t *op)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
xmlNode *xml_top = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(op != NULL, return);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
xml_top = create_xml_node(NULL, XML_LRM_TAG_RSC_OP);
|
|
rpm-build |
3ee90c |
crm_xml_add_int(xml_top, XML_LRM_ATTR_CALLID, op->call_id);
|
|
rpm-build |
3ee90c |
crm_xml_add(xml_top, XML_ATTR_TRANSITION_KEY, op->user_data);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->interval_ms > 0) {
|
|
rpm-build |
3ee90c |
char *op_id = generate_op_key(op->rsc_id, op->op_type, op->interval_ms);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Avoid deleting last_failure too (if it was a result of this recurring op failing) */
|
|
rpm-build |
3ee90c |
crm_xml_add(xml_top, XML_ATTR_ID, op_id);
|
|
rpm-build |
3ee90c |
free(op_id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("Erasing resource operation history for " CRM_OP_FMT " (call=%d)",
|
|
rpm-build |
3ee90c |
op->rsc_id, op->op_type, op->interval_ms, op->call_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
fsa_cib_conn->cmds->remove(fsa_cib_conn, XML_CIB_TAG_STATUS, xml_top,
|
|
rpm-build |
3ee90c |
cib_quorum_override);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_log_xml_trace(xml_top, "op:cancel");
|
|
rpm-build |
3ee90c |
free_xml(xml_top);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Define xpath to find LRM resource history entry by node and resource */
|
|
rpm-build |
3ee90c |
#define XPATH_HISTORY \
|
|
rpm-build |
3ee90c |
"/" XML_TAG_CIB "/" XML_CIB_TAG_STATUS \
|
|
rpm-build |
3ee90c |
"/" XML_CIB_TAG_STATE "[@" XML_ATTR_UNAME "='%s']" \
|
|
rpm-build |
3ee90c |
"/" XML_CIB_TAG_LRM "/" XML_LRM_TAG_RESOURCES \
|
|
rpm-build |
3ee90c |
"/" XML_LRM_TAG_RESOURCE "[@" XML_ATTR_ID "='%s']" \
|
|
rpm-build |
3ee90c |
"/" XML_LRM_TAG_RSC_OP
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* ... and also by operation key */
|
|
rpm-build |
3ee90c |
#define XPATH_HISTORY_ID XPATH_HISTORY \
|
|
rpm-build |
3ee90c |
"[@" XML_ATTR_ID "='%s']"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* ... and also by operation key and operation call ID */
|
|
rpm-build |
3ee90c |
#define XPATH_HISTORY_CALL XPATH_HISTORY \
|
|
rpm-build |
3ee90c |
"[@" XML_ATTR_ID "='%s' and @" XML_LRM_ATTR_CALLID "='%d']"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* ... and also by operation key and original operation key */
|
|
rpm-build |
3ee90c |
#define XPATH_HISTORY_ORIG XPATH_HISTORY \
|
|
rpm-build |
3ee90c |
"[@" XML_ATTR_ID "='%s' and @" XML_LRM_ATTR_TASK_KEY "='%s']"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \internal
|
|
rpm-build |
3ee90c |
* \brief Erase an LRM history entry from the CIB, given operation identifiers
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in] lrm_state LRM state of the node to clear history for
|
|
rpm-build |
3ee90c |
* \param[in] rsc_id Name of resource to clear history for
|
|
rpm-build |
3ee90c |
* \param[in] key Operation key of operation to clear history for
|
|
rpm-build |
3ee90c |
* \param[in] orig_op If specified, delete only if it has this original op
|
|
rpm-build |
3ee90c |
* \param[in] call_id If specified, delete entry only if it has this call ID
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
erase_lrm_history_by_id(lrm_state_t *lrm_state, const char *rsc_id,
|
|
rpm-build |
3ee90c |
const char *key, const char *orig_op, int call_id)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
char *op_xpath = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK((rsc_id != NULL) && (key != NULL), return);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (call_id > 0) {
|
|
rpm-build |
3ee90c |
op_xpath = crm_strdup_printf(XPATH_HISTORY_CALL,
|
|
rpm-build |
3ee90c |
lrm_state->node_name, rsc_id, key,
|
|
rpm-build |
3ee90c |
call_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (orig_op) {
|
|
rpm-build |
3ee90c |
op_xpath = crm_strdup_printf(XPATH_HISTORY_ORIG,
|
|
rpm-build |
3ee90c |
lrm_state->node_name, rsc_id, key,
|
|
rpm-build |
3ee90c |
orig_op);
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
op_xpath = crm_strdup_printf(XPATH_HISTORY_ID,
|
|
rpm-build |
3ee90c |
lrm_state->node_name, rsc_id, key);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("Erasing resource operation history for %s on %s (call=%d)",
|
|
rpm-build |
3ee90c |
key, rsc_id, call_id);
|
|
rpm-build |
3ee90c |
fsa_cib_conn->cmds->remove(fsa_cib_conn, op_xpath, NULL,
|
|
rpm-build |
3ee90c |
cib_quorum_override | cib_xpath);
|
|
rpm-build |
3ee90c |
free(op_xpath);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static inline gboolean
|
|
rpm-build |
3ee90c |
last_failed_matches_op(rsc_history_t *entry, const char *op, guint interval_ms)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
if (entry == NULL) {
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
if (op == NULL) {
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return (safe_str_eq(op, entry->failed->op_type)
|
|
rpm-build |
3ee90c |
&& (interval_ms == entry->failed->interval_ms));
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \internal
|
|
rpm-build |
3ee90c |
* \brief Clear a resource's last failure
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* Erase a resource's last failure on a particular node from both the
|
|
rpm-build |
3ee90c |
* LRM resource history in the CIB, and the resource history remembered
|
|
rpm-build |
3ee90c |
* for the LRM state.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in] rsc_id Resource name
|
|
rpm-build |
3ee90c |
* \param[in] node_name Node name
|
|
rpm-build |
3ee90c |
* \param[in] operation If specified, only clear if matching this operation
|
|
rpm-build |
3ee90c |
* \param[in] interval_ms If operation is specified, it has this interval
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
void
|
|
rpm-build |
3ee90c |
lrm_clear_last_failure(const char *rsc_id, const char *node_name,
|
|
rpm-build |
3ee90c |
const char *operation, guint interval_ms)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
char *op_key = NULL;
|
|
rpm-build |
3ee90c |
char *orig_op_key = NULL;
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
lrm_state = lrm_state_find(node_name);
|
|
rpm-build |
3ee90c |
if (lrm_state == NULL) {
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Erase from CIB */
|
|
rpm-build |
3ee90c |
op_key = generate_op_key(rsc_id, "last_failure", 0);
|
|
rpm-build |
3ee90c |
if (operation) {
|
|
rpm-build |
3ee90c |
orig_op_key = generate_op_key(rsc_id, operation, interval_ms);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
erase_lrm_history_by_id(lrm_state, rsc_id, op_key, orig_op_key, 0);
|
|
rpm-build |
3ee90c |
free(op_key);
|
|
rpm-build |
3ee90c |
free(orig_op_key);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Remove from memory */
|
|
rpm-build |
3ee90c |
if (lrm_state->resource_history) {
|
|
rpm-build |
3ee90c |
rsc_history_t *entry = g_hash_table_lookup(lrm_state->resource_history,
|
|
rpm-build |
3ee90c |
rsc_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (last_failed_matches_op(entry, operation, interval_ms)) {
|
|
rpm-build |
3ee90c |
lrmd_free_event(entry->failed);
|
|
rpm-build |
3ee90c |
entry->failed = NULL;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Returns: gboolean - cancellation is in progress */
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
cancel_op(lrm_state_t * lrm_state, const char *rsc_id, const char *key, int op, gboolean remove)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
int rc = pcmk_ok;
|
|
rpm-build |
3ee90c |
char *local_key = NULL;
|
|
|
2e9006 |
active_op_t *pending = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(op != 0, return FALSE);
|
|
rpm-build |
3ee90c |
CRM_CHECK(rsc_id != NULL, return FALSE);
|
|
rpm-build |
3ee90c |
if (key == NULL) {
|
|
rpm-build |
3ee90c |
local_key = make_stop_id(rsc_id, op);
|
|
rpm-build |
3ee90c |
key = local_key;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
pending = g_hash_table_lookup(lrm_state->pending_ops, key);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (pending) {
|
|
|
91c557 |
if (remove && is_not_set(pending->flags, active_op_remove)) {
|
|
|
91c557 |
set_bit(pending->flags, active_op_remove);
|
|
rpm-build |
3ee90c |
crm_debug("Scheduling %s for removal", key);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
|
91c557 |
if (is_set(pending->flags, active_op_cancelled)) {
|
|
rpm-build |
3ee90c |
crm_debug("Operation %s already cancelled", key);
|
|
rpm-build |
3ee90c |
free(local_key);
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
|
91c557 |
set_bit(pending->flags, active_op_cancelled);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_info("No pending op found for %s", key);
|
|
rpm-build |
3ee90c |
free(local_key);
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("Cancelling op %d for %s (%s)", op, rsc_id, key);
|
|
rpm-build |
3ee90c |
rc = lrm_state_cancel(lrm_state, pending->rsc_id, pending->op_type,
|
|
rpm-build |
3ee90c |
pending->interval_ms);
|
|
rpm-build |
3ee90c |
if (rc == pcmk_ok) {
|
|
rpm-build |
3ee90c |
crm_debug("Op %d for %s (%s): cancelled", op, rsc_id, key);
|
|
rpm-build |
3ee90c |
free(local_key);
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("Op %d for %s (%s): Nothing to cancel", op, rsc_id, key);
|
|
rpm-build |
3ee90c |
/* The caller needs to make sure the entry is
|
|
rpm-build |
3ee90c |
* removed from the pending_ops list
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* Usually by returning TRUE inside the worker function
|
|
rpm-build |
3ee90c |
* supplied to g_hash_table_foreach_remove()
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* Not removing the entry from pending_ops will block
|
|
rpm-build |
3ee90c |
* the node from shutting down
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
free(local_key);
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
struct cancel_data {
|
|
rpm-build |
3ee90c |
gboolean done;
|
|
rpm-build |
3ee90c |
gboolean remove;
|
|
rpm-build |
3ee90c |
const char *key;
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *rsc;
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state;
|
|
rpm-build |
3ee90c |
};
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
cancel_action_by_key(gpointer key, gpointer value, gpointer user_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
gboolean remove = FALSE;
|
|
rpm-build |
3ee90c |
struct cancel_data *data = user_data;
|
|
|
2e9006 |
active_op_t *op = value;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (crm_str_eq(op->op_key, data->key, TRUE)) {
|
|
rpm-build |
3ee90c |
data->done = TRUE;
|
|
rpm-build |
3ee90c |
remove = !cancel_op(data->lrm_state, data->rsc->id, key, op->call_id, data->remove);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return remove;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
cancel_op_key(lrm_state_t * lrm_state, lrmd_rsc_info_t * rsc, const char *key, gboolean remove)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
guint removed = 0;
|
|
rpm-build |
3ee90c |
struct cancel_data data;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(rsc != NULL, return FALSE);
|
|
rpm-build |
3ee90c |
CRM_CHECK(key != NULL, return FALSE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
data.key = key;
|
|
rpm-build |
3ee90c |
data.rsc = rsc;
|
|
rpm-build |
3ee90c |
data.done = FALSE;
|
|
rpm-build |
3ee90c |
data.remove = remove;
|
|
rpm-build |
3ee90c |
data.lrm_state = lrm_state;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
removed = g_hash_table_foreach_remove(lrm_state->pending_ops, cancel_action_by_key, &data);
|
|
rpm-build |
3ee90c |
crm_trace("Removed %u op cache entries, new size: %u",
|
|
rpm-build |
3ee90c |
removed, g_hash_table_size(lrm_state->pending_ops));
|
|
rpm-build |
3ee90c |
return data.done;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \internal
|
|
rpm-build |
3ee90c |
* \brief Retrieve resource information from LRM
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in] lrm_state LRM connection to use
|
|
rpm-build |
3ee90c |
* \param[in] rsc_xml XML containing resource configuration
|
|
rpm-build |
3ee90c |
* \param[in] do_create If true, register resource with LRM if not already
|
|
rpm-build |
3ee90c |
* \param[out] rsc_info Where to store resource information obtained from LRM
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval pcmk_ok Success (and rsc_info holds newly allocated result)
|
|
rpm-build |
3ee90c |
* \retval -EINVAL Required information is missing from arguments
|
|
rpm-build |
3ee90c |
* \retval -ENOTCONN No active connection to LRM
|
|
rpm-build |
3ee90c |
* \retval -ENODEV Resource not found
|
|
rpm-build |
3ee90c |
* \retval -errno Error communicating with executor when registering resource
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Caller is responsible for freeing result on success.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
static int
|
|
rpm-build |
3ee90c |
get_lrm_resource(lrm_state_t *lrm_state, xmlNode *rsc_xml, gboolean do_create,
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t **rsc_info)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
const char *id = ID(rsc_xml);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(lrm_state && rsc_xml && rsc_info, return -EINVAL);
|
|
rpm-build |
3ee90c |
CRM_CHECK(id, return -EINVAL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (lrm_state_is_connected(lrm_state) == FALSE) {
|
|
rpm-build |
3ee90c |
return -ENOTCONN;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("Retrieving resource information for %s from the executor", id);
|
|
rpm-build |
3ee90c |
*rsc_info = lrm_state_get_rsc_info(lrm_state, id, 0);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// If resource isn't known by ID, try clone name, if provided
|
|
rpm-build |
3ee90c |
if (!*rsc_info) {
|
|
rpm-build |
3ee90c |
const char *long_id = crm_element_value(rsc_xml, XML_ATTR_ID_LONG);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (long_id) {
|
|
rpm-build |
3ee90c |
*rsc_info = lrm_state_get_rsc_info(lrm_state, long_id, 0);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if ((*rsc_info == NULL) && do_create) {
|
|
rpm-build |
3ee90c |
const char *class = crm_element_value(rsc_xml, XML_AGENT_ATTR_CLASS);
|
|
rpm-build |
3ee90c |
const char *provider = crm_element_value(rsc_xml, XML_AGENT_ATTR_PROVIDER);
|
|
rpm-build |
3ee90c |
const char *type = crm_element_value(rsc_xml, XML_ATTR_TYPE);
|
|
rpm-build |
3ee90c |
int rc;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("Registering resource %s with the executor", id);
|
|
rpm-build |
3ee90c |
rc = lrm_state_register_rsc(lrm_state, id, class, provider, type,
|
|
rpm-build |
3ee90c |
lrmd_opt_drop_recurring);
|
|
rpm-build |
3ee90c |
if (rc != pcmk_ok) {
|
|
rpm-build |
3ee90c |
fsa_data_t *msg_data = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_err("Could not register resource %s with the executor on %s: %s "
|
|
rpm-build |
3ee90c |
CRM_XS " rc=%d",
|
|
rpm-build |
3ee90c |
id, lrm_state->node_name, pcmk_strerror(rc), rc);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Register this as an internal error if this involves the local
|
|
rpm-build |
3ee90c |
* executor. Otherwise, we're likely dealing with an unresponsive
|
|
rpm-build |
3ee90c |
* remote node, which is not an FSA failure.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
if (lrm_state_is_local(lrm_state) == TRUE) {
|
|
rpm-build |
3ee90c |
register_fsa_error(C_FSA_INTERNAL, I_FAIL, NULL);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return rc;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
*rsc_info = lrm_state_get_rsc_info(lrm_state, id, 0);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return *rsc_info? pcmk_ok : -ENODEV;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
delete_resource(lrm_state_t * lrm_state,
|
|
rpm-build |
3ee90c |
const char *id,
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t * rsc,
|
|
rpm-build |
3ee90c |
GHashTableIter * gIter,
|
|
rpm-build |
3ee90c |
const char *sys,
|
|
rpm-build |
3ee90c |
const char *host,
|
|
rpm-build |
3ee90c |
const char *user,
|
|
rpm-build |
3ee90c |
ha_msg_input_t * request,
|
|
rpm-build |
3ee90c |
gboolean unregister)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
int rc = pcmk_ok;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_info("Removing resource %s for %s (%s) on %s", id, sys, user ? user : "internal", host);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (rsc && unregister) {
|
|
rpm-build |
3ee90c |
rc = lrm_state_unregister_rsc(lrm_state, id, 0);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (rc == pcmk_ok) {
|
|
rpm-build |
3ee90c |
crm_trace("Resource '%s' deleted", id);
|
|
rpm-build |
3ee90c |
} else if (rc == -EINPROGRESS) {
|
|
rpm-build |
3ee90c |
crm_info("Deletion of resource '%s' pending", id);
|
|
rpm-build |
3ee90c |
if (request) {
|
|
rpm-build |
3ee90c |
struct pending_deletion_op_s *op = NULL;
|
|
rpm-build |
3ee90c |
char *ref = crm_element_value_copy(request->msg, XML_ATTR_REFERENCE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op = calloc(1, sizeof(struct pending_deletion_op_s));
|
|
rpm-build |
3ee90c |
op->rsc = strdup(rsc->id);
|
|
rpm-build |
3ee90c |
op->input = copy_ha_msg_input(request);
|
|
rpm-build |
3ee90c |
g_hash_table_insert(lrm_state->deletion_ops, ref, op);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_warn("Deletion of resource '%s' for %s (%s) on %s failed: %d",
|
|
rpm-build |
3ee90c |
id, sys, user ? user : "internal", host, rc);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
delete_rsc_entry(lrm_state, request, id, gIter, rc, user);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static int
|
|
rpm-build |
3ee90c |
get_fake_call_id(lrm_state_t *lrm_state, const char *rsc_id)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
int call_id = 999999999;
|
|
rpm-build |
3ee90c |
rsc_history_t *entry = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if(lrm_state) {
|
|
rpm-build |
3ee90c |
entry = g_hash_table_lookup(lrm_state->resource_history, rsc_id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Make sure the call id is greater than the last successful operation,
|
|
rpm-build |
3ee90c |
* otherwise the failure will not result in a possible recovery of the resource
|
|
rpm-build |
3ee90c |
* as it could appear the failure occurred before the successful start */
|
|
rpm-build |
3ee90c |
if (entry) {
|
|
rpm-build |
3ee90c |
call_id = entry->last_callid + 1;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (call_id < 0) {
|
|
rpm-build |
3ee90c |
call_id = 1;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return call_id;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
fake_op_status(lrm_state_t *lrm_state, lrmd_event_data_t *op, int op_status,
|
|
rpm-build |
3ee90c |
enum ocf_exitcode op_exitcode)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
op->call_id = get_fake_call_id(lrm_state, op->rsc_id);
|
|
rpm-build |
3ee90c |
op->t_run = time(NULL);
|
|
rpm-build |
3ee90c |
op->t_rcchange = op->t_run;
|
|
rpm-build |
3ee90c |
op->op_status = op_status;
|
|
rpm-build |
3ee90c |
op->rc = op_exitcode;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
force_reprobe(lrm_state_t *lrm_state, const char *from_sys,
|
|
rpm-build |
3ee90c |
const char *from_host, const char *user_name,
|
|
rpm-build |
3ee90c |
gboolean is_remote_node)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
GHashTableIter gIter;
|
|
rpm-build |
3ee90c |
rsc_history_t *entry = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_info("Clearing resource history on node %s", lrm_state->node_name);
|
|
rpm-build |
3ee90c |
g_hash_table_iter_init(&gIter, lrm_state->resource_history);
|
|
rpm-build |
3ee90c |
while (g_hash_table_iter_next(&gIter, NULL, (void **)&entry)) {
|
|
rpm-build |
3ee90c |
/* only unregister the resource during a reprobe if it is not a remote connection
|
|
rpm-build |
3ee90c |
* resource. otherwise unregistering the connection will terminate remote-node
|
|
rpm-build |
3ee90c |
* membership */
|
|
rpm-build |
3ee90c |
gboolean unregister = TRUE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (is_remote_lrmd_ra(NULL, NULL, entry->id)) {
|
|
rpm-build |
3ee90c |
lrm_state_t *remote_lrm_state = lrm_state_find(entry->id);
|
|
rpm-build |
3ee90c |
if (remote_lrm_state) {
|
|
rpm-build |
3ee90c |
/* when forcing a reprobe, make sure to clear remote node before
|
|
rpm-build |
3ee90c |
* clearing the remote node's connection resource */
|
|
rpm-build |
3ee90c |
force_reprobe(remote_lrm_state, from_sys, from_host, user_name, TRUE);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
unregister = FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
delete_resource(lrm_state, entry->id, &entry->rsc, &gIter, from_sys, from_host,
|
|
rpm-build |
3ee90c |
user_name, NULL, unregister);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Now delete the copy in the CIB */
|
|
|
409f23 |
controld_delete_node_state(lrm_state->node_name, controld_section_lrm,
|
|
|
409f23 |
cib_scope_local);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* Finally, _delete_ the value in pacemaker-attrd -- setting it to FALSE
|
|
rpm-build |
3ee90c |
* would result in the scheduler sending us back here again
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
update_attrd(lrm_state->node_name, CRM_OP_PROBED, NULL, user_name, is_remote_node);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \internal
|
|
rpm-build |
3ee90c |
* \brief Fail a requested action without actually executing it
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* For an action that can't be executed, process it similarly to an actual
|
|
rpm-build |
3ee90c |
* execution result, with specified error status (except for notify actions,
|
|
rpm-build |
3ee90c |
* which will always be treated as successful).
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in] lrm_state Executor connection that action is for
|
|
rpm-build |
3ee90c |
* \param[in] action Action XML from request
|
|
rpm-build |
3ee90c |
* \param[in] rc Desired return code to use
|
|
rpm-build |
3ee90c |
* \param[in] op_status Desired operation status to use
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
synthesize_lrmd_failure(lrm_state_t *lrm_state, xmlNode *action,
|
|
rpm-build |
3ee90c |
int op_status, enum ocf_exitcode rc)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
lrmd_event_data_t *op = NULL;
|
|
rpm-build |
3ee90c |
const char *operation = crm_element_value(action, XML_LRM_ATTR_TASK);
|
|
rpm-build |
3ee90c |
const char *target_node = crm_element_value(action, XML_LRM_ATTR_TARGET);
|
|
rpm-build |
3ee90c |
xmlNode *xml_rsc = find_xml_node(action, XML_CIB_TAG_RESOURCE, TRUE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if ((xml_rsc == NULL) || (ID(xml_rsc) == NULL)) {
|
|
rpm-build |
3ee90c |
/* @TODO Should we do something else, like direct ack? */
|
|
rpm-build |
3ee90c |
crm_info("Can't fake %s failure (%d) on %s without resource configuration",
|
|
rpm-build |
3ee90c |
crm_element_value(action, XML_LRM_ATTR_TASK_KEY), rc,
|
|
rpm-build |
3ee90c |
target_node);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if(operation == NULL) {
|
|
rpm-build |
3ee90c |
/* This probably came from crm_resource -C, nothing to do */
|
|
rpm-build |
3ee90c |
crm_info("Can't fake %s failure (%d) on %s without operation",
|
|
rpm-build |
3ee90c |
ID(xml_rsc), rc, target_node);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op = construct_op(lrm_state, action, ID(xml_rsc), operation);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_eq(operation, RSC_NOTIFY)) { // Notifications can't fail
|
|
rpm-build |
3ee90c |
fake_op_status(lrm_state, op, PCMK_LRM_OP_DONE, PCMK_OCF_OK);
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
fake_op_status(lrm_state, op, op_status, rc);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_info("Faking " CRM_OP_FMT " result (%d) on %s",
|
|
rpm-build |
3ee90c |
op->rsc_id, op->op_type, op->interval_ms, op->rc, target_node);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// Process the result as if it came from the LRM
|
|
rpm-build |
3ee90c |
process_lrm_event(lrm_state, op, NULL, action);
|
|
rpm-build |
3ee90c |
lrmd_free_event(op);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \internal
|
|
rpm-build |
3ee90c |
* \brief Get target of an LRM operation
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in] xml LRM operation data XML
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \return LRM operation target node name (local node or Pacemaker Remote node)
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
static const char *
|
|
rpm-build |
3ee90c |
lrm_op_target(xmlNode *xml)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
const char *target = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (xml) {
|
|
rpm-build |
3ee90c |
target = crm_element_value(xml, XML_LRM_ATTR_TARGET);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
if (target == NULL) {
|
|
rpm-build |
3ee90c |
target = fsa_our_uname;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return target;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
fail_lrm_resource(xmlNode *xml, lrm_state_t *lrm_state, const char *user_name,
|
|
rpm-build |
3ee90c |
const char *from_host, const char *from_sys)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
lrmd_event_data_t *op = NULL;
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *rsc = NULL;
|
|
rpm-build |
3ee90c |
xmlNode *xml_rsc = find_xml_node(xml, XML_CIB_TAG_RESOURCE, TRUE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(xml_rsc != NULL, return);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* The executor simply executes operations and reports the results, without
|
|
rpm-build |
3ee90c |
* any concept of success or failure, so to fail a resource, we must fake
|
|
rpm-build |
3ee90c |
* what a failure looks like.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* To do this, we create a fake executor operation event for the resource,
|
|
rpm-build |
3ee90c |
* and pass that event to the executor client callback so it will be
|
|
rpm-build |
3ee90c |
* processed as if it came from the executor.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
op = construct_op(lrm_state, xml, ID(xml_rsc), "asyncmon");
|
|
rpm-build |
3ee90c |
fake_op_status(lrm_state, op, PCMK_LRM_OP_DONE, PCMK_OCF_UNKNOWN_ERROR);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
free((char*) op->user_data);
|
|
rpm-build |
3ee90c |
op->user_data = NULL;
|
|
rpm-build |
3ee90c |
op->interval_ms = 0;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#if ENABLE_ACL
|
|
rpm-build |
3ee90c |
if (user_name && is_privileged(user_name) == FALSE) {
|
|
rpm-build |
3ee90c |
crm_err("%s does not have permission to fail %s", user_name, ID(xml_rsc));
|
|
rpm-build |
3ee90c |
send_direct_ack(from_host, from_sys, NULL, op, ID(xml_rsc));
|
|
rpm-build |
3ee90c |
lrmd_free_event(op);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
#endif
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (get_lrm_resource(lrm_state, xml_rsc, TRUE, &rsc) == pcmk_ok) {
|
|
rpm-build |
3ee90c |
crm_info("Failing resource %s...", rsc->id);
|
|
rpm-build |
3ee90c |
op->exit_reason = strdup("Simulated failure");
|
|
rpm-build |
3ee90c |
process_lrm_event(lrm_state, op, NULL, xml);
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_DONE;
|
|
rpm-build |
3ee90c |
op->rc = PCMK_OCF_OK;
|
|
rpm-build |
3ee90c |
lrmd_free_rsc_info(rsc);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_info("Cannot find/create resource in order to fail it...");
|
|
rpm-build |
3ee90c |
crm_log_xml_warn(xml, "bad input");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
send_direct_ack(from_host, from_sys, NULL, op, ID(xml_rsc));
|
|
rpm-build |
3ee90c |
lrmd_free_event(op);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
handle_refresh_op(lrm_state_t *lrm_state, const char *user_name,
|
|
rpm-build |
3ee90c |
const char *from_host, const char *from_sys)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
int rc = pcmk_ok;
|
|
rpm-build |
3ee90c |
xmlNode *fragment = do_lrm_query_internal(lrm_state, node_update_all);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
fsa_cib_update(XML_CIB_TAG_STATUS, fragment, cib_quorum_override, rc, user_name);
|
|
rpm-build |
3ee90c |
crm_info("Forced a local resource history refresh: call=%d", rc);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_neq(CRM_SYSTEM_CRMD, from_sys)) {
|
|
rpm-build |
3ee90c |
xmlNode *reply = create_request(CRM_OP_INVOKE_LRM, fragment, from_host,
|
|
rpm-build |
3ee90c |
from_sys, CRM_SYSTEM_LRMD,
|
|
rpm-build |
3ee90c |
fsa_our_uuid);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("ACK'ing refresh from %s (%s)", from_sys, from_host);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (relay_message(reply, TRUE) == FALSE) {
|
|
rpm-build |
3ee90c |
crm_log_xml_err(reply, "Unable to route reply");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
free_xml(reply);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
free_xml(fragment);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
handle_query_op(xmlNode *msg, lrm_state_t *lrm_state)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
xmlNode *data = do_lrm_query_internal(lrm_state, node_update_all);
|
|
rpm-build |
3ee90c |
xmlNode *reply = create_reply(msg, data);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (relay_message(reply, TRUE) == FALSE) {
|
|
rpm-build |
3ee90c |
crm_err("Unable to route reply");
|
|
rpm-build |
3ee90c |
crm_log_xml_err(reply, "reply");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
free_xml(reply);
|
|
rpm-build |
3ee90c |
free_xml(data);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
handle_reprobe_op(lrm_state_t *lrm_state, const char *from_sys,
|
|
rpm-build |
3ee90c |
const char *from_host, const char *user_name,
|
|
rpm-build |
3ee90c |
gboolean is_remote_node)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
crm_notice("Forcing the status of all resources to be redetected");
|
|
rpm-build |
3ee90c |
force_reprobe(lrm_state, from_sys, from_host, user_name, is_remote_node);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_neq(CRM_SYSTEM_PENGINE, from_sys)
|
|
rpm-build |
3ee90c |
&& safe_str_neq(CRM_SYSTEM_TENGINE, from_sys)) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
xmlNode *reply = create_request(CRM_OP_INVOKE_LRM, NULL, from_host,
|
|
rpm-build |
3ee90c |
from_sys, CRM_SYSTEM_LRMD,
|
|
rpm-build |
3ee90c |
fsa_our_uuid);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("ACK'ing re-probe from %s (%s)", from_sys, from_host);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (relay_message(reply, TRUE) == FALSE) {
|
|
rpm-build |
3ee90c |
crm_log_xml_err(reply, "Unable to route reply");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
free_xml(reply);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static bool do_lrm_cancel(ha_msg_input_t *input, lrm_state_t *lrm_state,
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *rsc, const char *from_host, const char *from_sys)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
char *op_key = NULL;
|
|
rpm-build |
3ee90c |
char *meta_key = NULL;
|
|
rpm-build |
3ee90c |
int call = 0;
|
|
rpm-build |
3ee90c |
const char *call_id = NULL;
|
|
rpm-build |
3ee90c |
const char *op_task = NULL;
|
|
rpm-build |
3ee90c |
const char *interval_ms_s = NULL;
|
|
rpm-build |
3ee90c |
gboolean in_progress = FALSE;
|
|
rpm-build |
3ee90c |
xmlNode *params = find_xml_node(input->xml, XML_TAG_ATTRS, TRUE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(params != NULL, return FALSE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
meta_key = crm_meta_name(XML_LRM_ATTR_INTERVAL_MS);
|
|
rpm-build |
3ee90c |
interval_ms_s = crm_element_value(params, meta_key);
|
|
rpm-build |
3ee90c |
free(meta_key);
|
|
rpm-build |
3ee90c |
CRM_CHECK(interval_ms_s != NULL, return FALSE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
meta_key = crm_meta_name(XML_LRM_ATTR_TASK);
|
|
rpm-build |
3ee90c |
op_task = crm_element_value(params, meta_key);
|
|
rpm-build |
3ee90c |
free(meta_key);
|
|
rpm-build |
3ee90c |
CRM_CHECK(op_task != NULL, return FALSE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
meta_key = crm_meta_name(XML_LRM_ATTR_CALLID);
|
|
rpm-build |
3ee90c |
call_id = crm_element_value(params, meta_key);
|
|
rpm-build |
3ee90c |
free(meta_key);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op_key = generate_op_key(rsc->id, op_task, crm_parse_ms(interval_ms_s));
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("Scheduler requested op %s (call=%s) be cancelled",
|
|
rpm-build |
3ee90c |
op_key, (call_id? call_id : "NA"));
|
|
rpm-build |
3ee90c |
call = crm_parse_int(call_id, "0");
|
|
rpm-build |
3ee90c |
if (call == 0) {
|
|
rpm-build |
3ee90c |
// Normal case when the scheduler cancels a recurring op
|
|
rpm-build |
3ee90c |
in_progress = cancel_op_key(lrm_state, rsc, op_key, TRUE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
// Normal case when the scheduler cancels an orphan op
|
|
rpm-build |
3ee90c |
in_progress = cancel_op(lrm_state, rsc->id, NULL, call, TRUE);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// Acknowledge cancellation operation if for a remote connection resource
|
|
rpm-build |
3ee90c |
if (!in_progress || is_remote_lrmd_ra(NULL, NULL, rsc->id)) {
|
|
rpm-build |
3ee90c |
char *op_id = make_stop_id(rsc->id, call);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (is_remote_lrmd_ra(NULL, NULL, rsc->id) == FALSE) {
|
|
rpm-build |
3ee90c |
crm_info("Nothing known about operation %d for %s", call, op_key);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
erase_lrm_history_by_id(lrm_state, rsc->id, op_key, NULL, call);
|
|
rpm-build |
3ee90c |
send_task_ok_ack(lrm_state, input, rsc->id, rsc, op_task,
|
|
rpm-build |
3ee90c |
from_host, from_sys);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* needed at least for cancellation of a remote operation */
|
|
rpm-build |
3ee90c |
g_hash_table_remove(lrm_state->pending_ops, op_id);
|
|
rpm-build |
3ee90c |
free(op_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
/* No ack is needed since abcdaa8, but peers with older versions
|
|
rpm-build |
3ee90c |
* in a rolling upgrade need one. We didn't bump the feature set
|
|
rpm-build |
3ee90c |
* at that commit, so we can only compare against the previous
|
|
rpm-build |
3ee90c |
* CRM version (3.0.8). If any peers have feature set 3.0.9 but
|
|
rpm-build |
3ee90c |
* not abcdaa8, they will time out waiting for the ack (no
|
|
rpm-build |
3ee90c |
* released versions of Pacemaker are affected).
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
const char *peer_version = crm_element_value(params, XML_ATTR_CRM_VERSION);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (compare_version(peer_version, "3.0.8") <= 0) {
|
|
rpm-build |
3ee90c |
crm_info("Sending compatibility ack for %s cancellation to %s (CRM version %s)",
|
|
rpm-build |
3ee90c |
op_key, from_host, peer_version);
|
|
rpm-build |
3ee90c |
send_task_ok_ack(lrm_state, input, rsc->id, rsc, op_task,
|
|
rpm-build |
3ee90c |
from_host, from_sys);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
free(op_key);
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
do_lrm_delete(ha_msg_input_t *input, lrm_state_t *lrm_state,
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *rsc, const char *from_sys, const char *from_host,
|
|
rpm-build |
3ee90c |
bool crm_rsc_delete, const char *user_name)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
gboolean unregister = TRUE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#if ENABLE_ACL
|
|
rpm-build |
3ee90c |
int cib_rc = delete_rsc_status(lrm_state, rsc->id,
|
|
rpm-build |
3ee90c |
cib_dryrun|cib_sync_call, user_name);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (cib_rc != pcmk_ok) {
|
|
rpm-build |
3ee90c |
lrmd_event_data_t *op = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_err("Could not delete resource status of %s for %s (user %s) on %s: %s"
|
|
rpm-build |
3ee90c |
CRM_XS " rc=%d",
|
|
rpm-build |
3ee90c |
rsc->id, from_sys, (user_name? user_name : "unknown"),
|
|
rpm-build |
3ee90c |
from_host, pcmk_strerror(cib_rc), cib_rc);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op = construct_op(lrm_state, input->xml, rsc->id, CRMD_ACTION_DELETE);
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_ERROR;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (cib_rc == -EACCES) {
|
|
rpm-build |
3ee90c |
op->rc = PCMK_OCF_INSUFFICIENT_PRIV;
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
op->rc = PCMK_OCF_UNKNOWN_ERROR;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
send_direct_ack(from_host, from_sys, NULL, op, rsc->id);
|
|
rpm-build |
3ee90c |
lrmd_free_event(op);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
#endif
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (crm_rsc_delete && is_remote_lrmd_ra(NULL, NULL, rsc->id)) {
|
|
rpm-build |
3ee90c |
unregister = FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
delete_resource(lrm_state, rsc->id, rsc, NULL, from_sys, from_host,
|
|
rpm-build |
3ee90c |
user_name, input, unregister);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* A_LRM_INVOKE */
|
|
rpm-build |
3ee90c |
void
|
|
rpm-build |
3ee90c |
do_lrm_invoke(long long action,
|
|
rpm-build |
3ee90c |
enum crmd_fsa_cause cause,
|
|
rpm-build |
3ee90c |
enum crmd_fsa_state cur_state,
|
|
rpm-build |
3ee90c |
enum crmd_fsa_input current_input, fsa_data_t * msg_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state = NULL;
|
|
rpm-build |
3ee90c |
const char *crm_op = NULL;
|
|
rpm-build |
3ee90c |
const char *from_sys = NULL;
|
|
rpm-build |
3ee90c |
const char *from_host = NULL;
|
|
rpm-build |
3ee90c |
const char *operation = NULL;
|
|
rpm-build |
3ee90c |
ha_msg_input_t *input = fsa_typed_data(fsa_dt_ha_msg);
|
|
rpm-build |
3ee90c |
const char *user_name = NULL;
|
|
rpm-build |
3ee90c |
const char *target_node = NULL;
|
|
rpm-build |
3ee90c |
gboolean is_remote_node = FALSE;
|
|
rpm-build |
3ee90c |
bool crm_rsc_delete = FALSE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
target_node = lrm_op_target(input->xml);
|
|
rpm-build |
3ee90c |
is_remote_node = safe_str_neq(target_node, fsa_our_uname);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
lrm_state = lrm_state_find(target_node);
|
|
rpm-build |
3ee90c |
if ((lrm_state == NULL) && is_remote_node) {
|
|
rpm-build |
3ee90c |
crm_err("Failing action because local node has never had connection to remote node %s",
|
|
rpm-build |
3ee90c |
target_node);
|
|
rpm-build |
3ee90c |
synthesize_lrmd_failure(NULL, input->xml, PCMK_LRM_OP_NOT_CONNECTED,
|
|
rpm-build |
3ee90c |
PCMK_OCF_UNKNOWN_ERROR);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
CRM_ASSERT(lrm_state != NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#if ENABLE_ACL
|
|
rpm-build |
3ee90c |
user_name = crm_acl_get_set_user(input->msg, F_CRM_USER, NULL);
|
|
rpm-build |
3ee90c |
crm_trace("Executor command from user '%s'", user_name);
|
|
rpm-build |
3ee90c |
#endif
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_op = crm_element_value(input->msg, F_CRM_TASK);
|
|
rpm-build |
3ee90c |
from_sys = crm_element_value(input->msg, F_CRM_SYS_FROM);
|
|
rpm-build |
3ee90c |
if (safe_str_neq(from_sys, CRM_SYSTEM_TENGINE)) {
|
|
rpm-build |
3ee90c |
from_host = crm_element_value(input->msg, F_CRM_HOST_FROM);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
crm_trace("Executor %s command from %s", crm_op, from_sys);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_eq(crm_op, CRM_OP_LRM_DELETE)) {
|
|
rpm-build |
3ee90c |
crm_rsc_delete = TRUE; // Only crm_resource uses this op
|
|
rpm-build |
3ee90c |
operation = CRMD_ACTION_DELETE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (safe_str_eq(crm_op, CRM_OP_LRM_FAIL)) {
|
|
rpm-build |
3ee90c |
fail_lrm_resource(input->xml, lrm_state, user_name, from_host,
|
|
rpm-build |
3ee90c |
from_sys);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (input->xml != NULL) {
|
|
rpm-build |
3ee90c |
operation = crm_element_value(input->xml, XML_LRM_ATTR_TASK);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_eq(crm_op, CRM_OP_LRM_REFRESH)) {
|
|
rpm-build |
3ee90c |
handle_refresh_op(lrm_state, user_name, from_host, from_sys);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (safe_str_eq(crm_op, CRM_OP_LRM_QUERY)) {
|
|
rpm-build |
3ee90c |
handle_query_op(input->msg, lrm_state);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (safe_str_eq(operation, CRM_OP_PROBED)) {
|
|
rpm-build |
3ee90c |
update_attrd(lrm_state->node_name, CRM_OP_PROBED, XML_BOOLEAN_TRUE,
|
|
rpm-build |
3ee90c |
user_name, is_remote_node);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (safe_str_eq(operation, CRM_OP_REPROBE)
|
|
rpm-build |
3ee90c |
|| safe_str_eq(crm_op, CRM_OP_REPROBE)) {
|
|
rpm-build |
3ee90c |
handle_reprobe_op(lrm_state, from_sys, from_host, user_name,
|
|
rpm-build |
3ee90c |
is_remote_node);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (operation != NULL) {
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *rsc = NULL;
|
|
rpm-build |
3ee90c |
xmlNode *xml_rsc = find_xml_node(input->xml, XML_CIB_TAG_RESOURCE, TRUE);
|
|
rpm-build |
3ee90c |
gboolean create_rsc = safe_str_neq(operation, CRMD_ACTION_DELETE);
|
|
rpm-build |
3ee90c |
int rc;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// We can't return anything meaningful without a resource ID
|
|
rpm-build |
3ee90c |
CRM_CHECK(xml_rsc && ID(xml_rsc), return);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
rc = get_lrm_resource(lrm_state, xml_rsc, create_rsc, &rsc);
|
|
rpm-build |
3ee90c |
if (rc == -ENOTCONN) {
|
|
rpm-build |
3ee90c |
synthesize_lrmd_failure(lrm_state, input->xml,
|
|
rpm-build |
3ee90c |
PCMK_LRM_OP_NOT_CONNECTED,
|
|
rpm-build |
3ee90c |
PCMK_OCF_UNKNOWN_ERROR);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if ((rc < 0) && !create_rsc) {
|
|
rpm-build |
3ee90c |
/* Delete of malformed or nonexistent resource
|
|
rpm-build |
3ee90c |
* (deleting something that does not exist is a success)
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
crm_notice("Not registering resource '%s' for a %s event "
|
|
rpm-build |
3ee90c |
CRM_XS " get-rc=%d (%s) transition-key=%s",
|
|
rpm-build |
3ee90c |
ID(xml_rsc), operation,
|
|
rpm-build |
3ee90c |
rc, pcmk_strerror(rc), ID(input->xml));
|
|
rpm-build |
3ee90c |
delete_rsc_entry(lrm_state, input, ID(xml_rsc), NULL, pcmk_ok,
|
|
rpm-build |
3ee90c |
user_name);
|
|
rpm-build |
3ee90c |
send_task_ok_ack(lrm_state, input, ID(xml_rsc), NULL, operation,
|
|
rpm-build |
3ee90c |
from_host, from_sys);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (rc == -EINVAL) {
|
|
rpm-build |
3ee90c |
// Resource operation on malformed resource
|
|
rpm-build |
3ee90c |
crm_err("Invalid resource definition for %s", ID(xml_rsc));
|
|
rpm-build |
3ee90c |
crm_log_xml_warn(input->msg, "invalid resource");
|
|
rpm-build |
3ee90c |
synthesize_lrmd_failure(lrm_state, input->xml, PCMK_LRM_OP_ERROR,
|
|
rpm-build |
3ee90c |
PCMK_OCF_NOT_CONFIGURED); // fatal error
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (rc < 0) {
|
|
rpm-build |
3ee90c |
// Error communicating with the executor
|
|
rpm-build |
3ee90c |
crm_err("Could not register resource '%s' with executor: %s "
|
|
rpm-build |
3ee90c |
CRM_XS " rc=%d",
|
|
rpm-build |
3ee90c |
ID(xml_rsc), pcmk_strerror(rc), rc);
|
|
rpm-build |
3ee90c |
crm_log_xml_warn(input->msg, "failed registration");
|
|
rpm-build |
3ee90c |
synthesize_lrmd_failure(lrm_state, input->xml, PCMK_LRM_OP_ERROR,
|
|
rpm-build |
3ee90c |
PCMK_OCF_INVALID_PARAM); // hard error
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_eq(operation, CRMD_ACTION_CANCEL)) {
|
|
rpm-build |
3ee90c |
if (!do_lrm_cancel(input, lrm_state, rsc, from_host, from_sys)) {
|
|
rpm-build |
3ee90c |
crm_log_xml_warn(input->xml, "Bad command");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (safe_str_eq(operation, CRMD_ACTION_DELETE)) {
|
|
rpm-build |
3ee90c |
do_lrm_delete(input, lrm_state, rsc, from_sys, from_host,
|
|
rpm-build |
3ee90c |
crm_rsc_delete, user_name);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
|
7201e2 |
do_lrm_rsc_op(lrm_state, rsc, operation, input->xml);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
lrmd_free_rsc_info(rsc);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_err("Cannot perform operation %s of unknown type", crm_str(crm_op));
|
|
rpm-build |
3ee90c |
register_fsa_error(C_FSA_INTERNAL, I_ERROR, NULL);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static lrmd_event_data_t *
|
|
rpm-build |
3ee90c |
construct_op(lrm_state_t * lrm_state, xmlNode * rsc_op, const char *rsc_id, const char *operation)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
lrmd_event_data_t *op = NULL;
|
|
rpm-build |
3ee90c |
const char *op_delay = NULL;
|
|
rpm-build |
3ee90c |
const char *op_timeout = NULL;
|
|
rpm-build |
3ee90c |
const char *interval_ms_s = NULL;
|
|
rpm-build |
3ee90c |
GHashTable *params = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
const char *transition = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_ASSERT(rsc_id && operation);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op = calloc(1, sizeof(lrmd_event_data_t));
|
|
rpm-build |
3ee90c |
CRM_ASSERT(op != NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op->type = lrmd_event_exec_complete;
|
|
rpm-build |
3ee90c |
op->op_type = strdup(operation);
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_PENDING;
|
|
rpm-build |
3ee90c |
op->rc = -1;
|
|
rpm-build |
3ee90c |
op->rsc_id = strdup(rsc_id);
|
|
rpm-build |
3ee90c |
op->interval_ms = 0;
|
|
rpm-build |
3ee90c |
op->timeout = 0;
|
|
rpm-build |
3ee90c |
op->start_delay = 0;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (rsc_op == NULL) {
|
|
rpm-build |
3ee90c |
CRM_LOG_ASSERT(safe_str_eq(CRMD_ACTION_STOP, operation));
|
|
rpm-build |
3ee90c |
op->user_data = NULL;
|
|
rpm-build |
3ee90c |
/* the stop_all_resources() case
|
|
rpm-build |
3ee90c |
* by definition there is no DC (or they'd be shutting
|
|
rpm-build |
3ee90c |
* us down).
|
|
rpm-build |
3ee90c |
* So we should put our version here.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
op->params = crm_str_table_new();
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
g_hash_table_insert(op->params, strdup(XML_ATTR_CRM_VERSION), strdup(CRM_FEATURE_SET));
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("Constructed %s op for %s", operation, rsc_id);
|
|
rpm-build |
3ee90c |
return op;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
params = xml2list(rsc_op);
|
|
rpm-build |
3ee90c |
g_hash_table_remove(params, CRM_META "_op_target_rc");
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op_delay = crm_meta_value(params, XML_OP_ATTR_START_DELAY);
|
|
rpm-build |
3ee90c |
op_timeout = crm_meta_value(params, XML_ATTR_TIMEOUT);
|
|
rpm-build |
3ee90c |
interval_ms_s = crm_meta_value(params, XML_LRM_ATTR_INTERVAL_MS);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op->interval_ms = crm_parse_ms(interval_ms_s);
|
|
rpm-build |
3ee90c |
op->timeout = crm_parse_int(op_timeout, "0");
|
|
rpm-build |
3ee90c |
op->start_delay = crm_parse_int(op_delay, "0");
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#if ENABLE_VERSIONED_ATTRS
|
|
rpm-build |
3ee90c |
// Resolve any versioned parameters
|
|
rpm-build |
3ee90c |
if (lrm_state && safe_str_neq(op->op_type, RSC_METADATA)
|
|
rpm-build |
3ee90c |
&& safe_str_neq(op->op_type, CRMD_ACTION_DELETE)
|
|
rpm-build |
3ee90c |
&& !is_remote_lrmd_ra(NULL, NULL, rsc_id)) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// Resource info *should* already be cached, so we don't get executor call
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *rsc = lrm_state_get_rsc_info(lrm_state, rsc_id, 0);
|
|
rpm-build |
3ee90c |
struct ra_metadata_s *metadata;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
metadata = metadata_cache_get(lrm_state->metadata_cache, rsc);
|
|
rpm-build |
3ee90c |
if (metadata) {
|
|
rpm-build |
3ee90c |
xmlNode *versioned_attrs = NULL;
|
|
rpm-build |
3ee90c |
GHashTable *hash = NULL;
|
|
rpm-build |
3ee90c |
char *key = NULL;
|
|
rpm-build |
3ee90c |
char *value = NULL;
|
|
rpm-build |
3ee90c |
GHashTableIter iter;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
versioned_attrs = first_named_child(rsc_op, XML_TAG_OP_VER_ATTRS);
|
|
rpm-build |
3ee90c |
hash = pe_unpack_versioned_parameters(versioned_attrs, metadata->ra_version);
|
|
rpm-build |
3ee90c |
g_hash_table_iter_init(&iter, hash);
|
|
rpm-build |
3ee90c |
while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
|
|
rpm-build |
3ee90c |
g_hash_table_iter_steal(&iter);
|
|
rpm-build |
3ee90c |
g_hash_table_replace(params, key, value);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
g_hash_table_destroy(hash);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
versioned_attrs = first_named_child(rsc_op, XML_TAG_OP_VER_META);
|
|
rpm-build |
3ee90c |
hash = pe_unpack_versioned_parameters(versioned_attrs, metadata->ra_version);
|
|
rpm-build |
3ee90c |
g_hash_table_iter_init(&iter, hash);
|
|
rpm-build |
3ee90c |
while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
|
|
rpm-build |
3ee90c |
g_hash_table_replace(params, crm_meta_name(key), strdup(value));
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_eq(key, XML_ATTR_TIMEOUT)) {
|
|
rpm-build |
3ee90c |
op->timeout = crm_parse_int(value, "0");
|
|
rpm-build |
3ee90c |
} else if (safe_str_eq(key, XML_OP_ATTR_START_DELAY)) {
|
|
rpm-build |
3ee90c |
op->start_delay = crm_parse_int(value, "0");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
g_hash_table_destroy(hash);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
versioned_attrs = first_named_child(rsc_op, XML_TAG_RSC_VER_ATTRS);
|
|
rpm-build |
3ee90c |
hash = pe_unpack_versioned_parameters(versioned_attrs, metadata->ra_version);
|
|
rpm-build |
3ee90c |
g_hash_table_iter_init(&iter, hash);
|
|
rpm-build |
3ee90c |
while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
|
|
rpm-build |
3ee90c |
g_hash_table_iter_steal(&iter);
|
|
rpm-build |
3ee90c |
g_hash_table_replace(params, key, value);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
g_hash_table_destroy(hash);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
lrmd_free_rsc_info(rsc);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
#endif
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_neq(operation, RSC_STOP)) {
|
|
rpm-build |
3ee90c |
op->params = params;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
rsc_history_t *entry = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (lrm_state) {
|
|
rpm-build |
3ee90c |
entry = g_hash_table_lookup(lrm_state->resource_history, rsc_id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* If we do not have stop parameters cached, use
|
|
rpm-build |
3ee90c |
* whatever we are given */
|
|
rpm-build |
3ee90c |
if (!entry || !entry->stop_params) {
|
|
rpm-build |
3ee90c |
op->params = params;
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
/* Copy the cached parameter list so that we stop the resource
|
|
rpm-build |
3ee90c |
* with the old attributes, not the new ones */
|
|
rpm-build |
3ee90c |
op->params = crm_str_table_new();
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
g_hash_table_foreach(params, copy_meta_keys, op->params);
|
|
rpm-build |
3ee90c |
g_hash_table_foreach(entry->stop_params, copy_instance_keys, op->params);
|
|
rpm-build |
3ee90c |
g_hash_table_destroy(params);
|
|
rpm-build |
3ee90c |
params = NULL;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* sanity */
|
|
rpm-build |
3ee90c |
if (op->timeout <= 0) {
|
|
rpm-build |
3ee90c |
op->timeout = op->interval_ms;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
if (op->start_delay < 0) {
|
|
rpm-build |
3ee90c |
op->start_delay = 0;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
transition = crm_element_value(rsc_op, XML_ATTR_TRANSITION_KEY);
|
|
rpm-build |
3ee90c |
CRM_CHECK(transition != NULL, return op);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op->user_data = strdup(transition);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->interval_ms != 0) {
|
|
rpm-build |
3ee90c |
if (safe_str_eq(operation, CRMD_ACTION_START)
|
|
rpm-build |
3ee90c |
|| safe_str_eq(operation, CRMD_ACTION_STOP)) {
|
|
rpm-build |
3ee90c |
crm_err("Start and Stop actions cannot have an interval: %u",
|
|
rpm-build |
3ee90c |
op->interval_ms);
|
|
rpm-build |
3ee90c |
op->interval_ms = 0;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_trace("Constructed %s op for %s: interval=%u",
|
|
rpm-build |
3ee90c |
operation, rsc_id, op->interval_ms);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return op;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
void
|
|
rpm-build |
3ee90c |
send_direct_ack(const char *to_host, const char *to_sys,
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t * rsc, lrmd_event_data_t * op, const char *rsc_id)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
xmlNode *reply = NULL;
|
|
rpm-build |
3ee90c |
xmlNode *update, *iter;
|
|
rpm-build |
3ee90c |
crm_node_t *peer = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(op != NULL, return);
|
|
rpm-build |
3ee90c |
if (op->rsc_id == NULL) {
|
|
rpm-build |
3ee90c |
CRM_ASSERT(rsc_id != NULL);
|
|
rpm-build |
3ee90c |
op->rsc_id = strdup(rsc_id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
if (to_sys == NULL) {
|
|
rpm-build |
3ee90c |
to_sys = CRM_SYSTEM_TENGINE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
peer = crm_get_peer(0, fsa_our_uname);
|
|
rpm-build |
3ee90c |
update = create_node_state_update(peer, node_update_none, NULL,
|
|
rpm-build |
3ee90c |
__FUNCTION__);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
iter = create_xml_node(update, XML_CIB_TAG_LRM);
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_ATTR_ID, fsa_our_uuid);
|
|
rpm-build |
3ee90c |
iter = create_xml_node(iter, XML_LRM_TAG_RESOURCES);
|
|
rpm-build |
3ee90c |
iter = create_xml_node(iter, XML_LRM_TAG_RESOURCE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_ATTR_ID, op->rsc_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
build_operation_update(iter, rsc, op, fsa_our_uname, __FUNCTION__);
|
|
rpm-build |
3ee90c |
reply = create_request(CRM_OP_INVOKE_LRM, update, to_host, to_sys, CRM_SYSTEM_LRMD, NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_log_xml_trace(update, "ACK Update");
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("ACK'ing resource op " CRM_OP_FMT " from %s: %s",
|
|
rpm-build |
3ee90c |
op->rsc_id, op->op_type, op->interval_ms, op->user_data,
|
|
rpm-build |
3ee90c |
crm_element_value(reply, XML_ATTR_REFERENCE));
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (relay_message(reply, TRUE) == FALSE) {
|
|
rpm-build |
3ee90c |
crm_log_xml_err(reply, "Unable to route reply");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
free_xml(update);
|
|
rpm-build |
3ee90c |
free_xml(reply);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
gboolean
|
|
rpm-build |
3ee90c |
verify_stopped(enum crmd_fsa_state cur_state, int log_level)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
gboolean res = TRUE;
|
|
rpm-build |
3ee90c |
GList *lrm_state_list = lrm_state_get_list();
|
|
rpm-build |
3ee90c |
GList *state_entry;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
for (state_entry = lrm_state_list; state_entry != NULL; state_entry = state_entry->next) {
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state = state_entry->data;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (!lrm_state_verify_stopped(lrm_state, cur_state, log_level)) {
|
|
rpm-build |
3ee90c |
/* keep iterating through all even when false is returned */
|
|
rpm-build |
3ee90c |
res = FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
set_bit(fsa_input_register, R_SENT_RSC_STOP);
|
|
rpm-build |
3ee90c |
g_list_free(lrm_state_list); lrm_state_list = NULL;
|
|
rpm-build |
3ee90c |
return res;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
struct stop_recurring_action_s {
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *rsc;
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state;
|
|
rpm-build |
3ee90c |
};
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
stop_recurring_action_by_rsc(gpointer key, gpointer value, gpointer user_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
gboolean remove = FALSE;
|
|
rpm-build |
3ee90c |
struct stop_recurring_action_s *event = user_data;
|
|
|
2e9006 |
active_op_t *op = value;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if ((op->interval_ms != 0)
|
|
rpm-build |
3ee90c |
&& crm_str_eq(op->rsc_id, event->rsc->id, TRUE)) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_debug("Cancelling op %d for %s (%s)", op->call_id, op->rsc_id, (char*)key);
|
|
rpm-build |
3ee90c |
remove = !cancel_op(event->lrm_state, event->rsc->id, key, op->call_id, FALSE);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return remove;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static gboolean
|
|
rpm-build |
3ee90c |
stop_recurring_actions(gpointer key, gpointer value, gpointer user_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
gboolean remove = FALSE;
|
|
rpm-build |
3ee90c |
lrm_state_t *lrm_state = user_data;
|
|
|
2e9006 |
active_op_t *op = value;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->interval_ms != 0) {
|
|
rpm-build |
3ee90c |
crm_info("Cancelling op %d for %s (%s)", op->call_id, op->rsc_id,
|
|
rpm-build |
3ee90c |
(const char *) key);
|
|
rpm-build |
3ee90c |
remove = !cancel_op(lrm_state, op->rsc_id, key, op->call_id, FALSE);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return remove;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
record_pending_op(const char *node_name, lrmd_rsc_info_t *rsc, lrmd_event_data_t *op)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
const char *record_pending = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(node_name != NULL, return);
|
|
rpm-build |
3ee90c |
CRM_CHECK(rsc != NULL, return);
|
|
rpm-build |
3ee90c |
CRM_CHECK(op != NULL, return);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// Never record certain operation types as pending
|
|
rpm-build |
3ee90c |
if ((op->op_type == NULL) || (op->params == NULL)
|
|
rpm-build |
3ee90c |
|| !controld_action_is_recordable(op->op_type)) {
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// defaults to true
|
|
rpm-build |
3ee90c |
record_pending = crm_meta_value(op->params, XML_OP_ATTR_PENDING);
|
|
rpm-build |
3ee90c |
if (record_pending && !crm_is_true(record_pending)) {
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op->call_id = -1;
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_PENDING;
|
|
rpm-build |
3ee90c |
op->rc = PCMK_OCF_UNKNOWN;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op->t_run = time(NULL);
|
|
rpm-build |
3ee90c |
op->t_rcchange = op->t_run;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* write a "pending" entry to the CIB, inhibit notification */
|
|
rpm-build |
3ee90c |
crm_debug("Recording pending op " CRM_OP_FMT " on %s in the CIB",
|
|
rpm-build |
3ee90c |
op->rsc_id, op->op_type, op->interval_ms, node_name);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
do_update_resource(node_name, rsc, op);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
|
7201e2 |
do_lrm_rsc_op(lrm_state_t *lrm_state, lrmd_rsc_info_t *rsc,
|
|
|
7201e2 |
const char *operation, xmlNode *msg)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
int call_id = 0;
|
|
rpm-build |
3ee90c |
char *op_id = NULL;
|
|
rpm-build |
3ee90c |
lrmd_event_data_t *op = NULL;
|
|
rpm-build |
3ee90c |
lrmd_key_value_t *params = NULL;
|
|
rpm-build |
3ee90c |
fsa_data_t *msg_data = NULL;
|
|
rpm-build |
3ee90c |
const char *transition = NULL;
|
|
rpm-build |
3ee90c |
gboolean stop_recurring = FALSE;
|
|
rpm-build |
3ee90c |
bool send_nack = FALSE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(rsc != NULL, return);
|
|
rpm-build |
3ee90c |
CRM_CHECK(operation != NULL, return);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (msg != NULL) {
|
|
rpm-build |
3ee90c |
transition = crm_element_value(msg, XML_ATTR_TRANSITION_KEY);
|
|
rpm-build |
3ee90c |
if (transition == NULL) {
|
|
rpm-build |
3ee90c |
crm_log_xml_err(msg, "Missing transition number");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op = construct_op(lrm_state, msg, rsc->id, operation);
|
|
rpm-build |
3ee90c |
CRM_CHECK(op != NULL, return);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (is_remote_lrmd_ra(NULL, NULL, rsc->id)
|
|
rpm-build |
3ee90c |
&& (op->interval_ms == 0)
|
|
rpm-build |
3ee90c |
&& strcmp(operation, CRMD_ACTION_MIGRATE) == 0) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* pcmk remote connections are a special use case.
|
|
rpm-build |
3ee90c |
* We never ever want to stop monitoring a connection resource until
|
|
rpm-build |
3ee90c |
* the entire migration has completed. If the connection is unexpectedly
|
|
rpm-build |
3ee90c |
* severed, even during a migration, this is an event we must detect.*/
|
|
rpm-build |
3ee90c |
stop_recurring = FALSE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if ((op->interval_ms == 0)
|
|
rpm-build |
3ee90c |
&& strcmp(operation, CRMD_ACTION_STATUS) != 0
|
|
rpm-build |
3ee90c |
&& strcmp(operation, CRMD_ACTION_NOTIFY) != 0) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* stop any previous monitor operations before changing the resource state */
|
|
rpm-build |
3ee90c |
stop_recurring = TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (stop_recurring == TRUE) {
|
|
rpm-build |
3ee90c |
guint removed = 0;
|
|
rpm-build |
3ee90c |
struct stop_recurring_action_s data;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
data.rsc = rsc;
|
|
rpm-build |
3ee90c |
data.lrm_state = lrm_state;
|
|
rpm-build |
3ee90c |
removed = g_hash_table_foreach_remove(
|
|
rpm-build |
3ee90c |
lrm_state->pending_ops, stop_recurring_action_by_rsc, &data);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (removed) {
|
|
rpm-build |
3ee90c |
crm_debug("Stopped %u recurring operation%s in preparation for " CRM_OP_FMT,
|
|
rpm-build |
3ee90c |
removed, s_if_plural(removed),
|
|
rpm-build |
3ee90c |
rsc->id, operation, op->interval_ms);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* now do the op */
|
|
rpm-build |
3ee90c |
crm_info("Performing key=%s op=" CRM_OP_FMT,
|
|
rpm-build |
3ee90c |
transition, rsc->id, operation, op->interval_ms);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (is_set(fsa_input_register, R_SHUTDOWN) && safe_str_eq(operation, RSC_START)) {
|
|
rpm-build |
3ee90c |
register_fsa_input(C_SHUTDOWN, I_SHUTDOWN, NULL);
|
|
rpm-build |
3ee90c |
send_nack = TRUE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (fsa_state != S_NOT_DC
|
|
rpm-build |
3ee90c |
&& fsa_state != S_POLICY_ENGINE /* Recalculating */
|
|
rpm-build |
3ee90c |
&& fsa_state != S_TRANSITION_ENGINE
|
|
rpm-build |
3ee90c |
&& safe_str_neq(operation, CRMD_ACTION_STOP)) {
|
|
rpm-build |
3ee90c |
send_nack = TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if(send_nack) {
|
|
rpm-build |
3ee90c |
crm_notice("Discarding attempt to perform action %s on %s in state %s (shutdown=%s)",
|
|
rpm-build |
3ee90c |
operation, rsc->id, fsa_state2string(fsa_state),
|
|
rpm-build |
3ee90c |
is_set(fsa_input_register, R_SHUTDOWN)?"true":"false");
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op->rc = PCMK_OCF_UNKNOWN_ERROR;
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_INVALID;
|
|
rpm-build |
3ee90c |
send_direct_ack(NULL, NULL, rsc, op, rsc->id);
|
|
rpm-build |
3ee90c |
lrmd_free_event(op);
|
|
rpm-build |
3ee90c |
free(op_id);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
record_pending_op(lrm_state->node_name, rsc, op);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op_id = generate_op_key(rsc->id, op->op_type, op->interval_ms);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->interval_ms > 0) {
|
|
rpm-build |
3ee90c |
/* cancel it so we can then restart it without conflict */
|
|
rpm-build |
3ee90c |
cancel_op_key(lrm_state, rsc, op_id, FALSE);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->params) {
|
|
rpm-build |
3ee90c |
char *key = NULL;
|
|
rpm-build |
3ee90c |
char *value = NULL;
|
|
rpm-build |
3ee90c |
GHashTableIter iter;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
g_hash_table_iter_init(&iter, op->params);
|
|
rpm-build |
3ee90c |
while (g_hash_table_iter_next(&iter, (gpointer *) & key, (gpointer *) & value)) {
|
|
rpm-build |
3ee90c |
params = lrmd_key_value_add(params, key, value);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
call_id = lrm_state_exec(lrm_state, rsc->id, op->op_type, op->user_data,
|
|
rpm-build |
3ee90c |
op->interval_ms, op->timeout, op->start_delay,
|
|
rpm-build |
3ee90c |
params);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (call_id <= 0 && lrm_state_is_local(lrm_state)) {
|
|
rpm-build |
3ee90c |
crm_err("Operation %s on %s failed: %d", operation, rsc->id, call_id);
|
|
rpm-build |
3ee90c |
register_fsa_error(C_FSA_INTERNAL, I_FAIL, NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (call_id <= 0) {
|
|
rpm-build |
3ee90c |
crm_err("Operation %s on resource %s failed to execute on remote node %s: %d",
|
|
rpm-build |
3ee90c |
operation, rsc->id, lrm_state->node_name, call_id);
|
|
rpm-build |
3ee90c |
fake_op_status(lrm_state, op, PCMK_LRM_OP_DONE, PCMK_OCF_UNKNOWN_ERROR);
|
|
rpm-build |
3ee90c |
process_lrm_event(lrm_state, op, NULL, NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
/* record all operations so we can wait
|
|
rpm-build |
3ee90c |
* for them to complete during shutdown
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
char *call_id_s = make_stop_id(rsc->id, call_id);
|
|
|
2e9006 |
active_op_t *pending = NULL;
|
|
rpm-build |
3ee90c |
|
|
|
2e9006 |
pending = calloc(1, sizeof(active_op_t));
|
|
rpm-build |
3ee90c |
crm_trace("Recording pending op: %d - %s %s", call_id, op_id, call_id_s);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
pending->call_id = call_id;
|
|
rpm-build |
3ee90c |
pending->interval_ms = op->interval_ms;
|
|
rpm-build |
3ee90c |
pending->op_type = strdup(operation);
|
|
rpm-build |
3ee90c |
pending->op_key = strdup(op_id);
|
|
rpm-build |
3ee90c |
pending->rsc_id = strdup(rsc->id);
|
|
rpm-build |
3ee90c |
pending->start_time = time(NULL);
|
|
rpm-build |
3ee90c |
pending->user_data = op->user_data? strdup(op->user_data) : NULL;
|
|
rpm-build |
3ee90c |
g_hash_table_replace(lrm_state->pending_ops, call_id_s, pending);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if ((op->interval_ms > 0)
|
|
rpm-build |
3ee90c |
&& (op->start_delay > START_DELAY_THRESHOLD)) {
|
|
rpm-build |
3ee90c |
int target_rc = 0;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_info("Faking confirmation of %s: execution postponed for over 5 minutes", op_id);
|
|
rpm-build |
3ee90c |
decode_transition_key(op->user_data, NULL, NULL, NULL, &target_rc);
|
|
rpm-build |
3ee90c |
op->rc = target_rc;
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_DONE;
|
|
rpm-build |
3ee90c |
send_direct_ack(NULL, NULL, rsc, op, rsc->id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
pending->params = op->params;
|
|
rpm-build |
3ee90c |
op->params = NULL;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
free(op_id);
|
|
rpm-build |
3ee90c |
lrmd_free_event(op);
|
|
rpm-build |
3ee90c |
return;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
int last_resource_update = 0;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static void
|
|
rpm-build |
3ee90c |
cib_rsc_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void *user_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
switch (rc) {
|
|
rpm-build |
3ee90c |
case pcmk_ok:
|
|
rpm-build |
3ee90c |
case -pcmk_err_diff_failed:
|
|
rpm-build |
3ee90c |
case -pcmk_err_diff_resync:
|
|
rpm-build |
3ee90c |
crm_trace("Resource update %d complete: rc=%d", call_id, rc);
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
default:
|
|
rpm-build |
3ee90c |
crm_warn("Resource update %d failed: (rc=%d) %s", call_id, rc, pcmk_strerror(rc));
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (call_id == last_resource_update) {
|
|
rpm-build |
3ee90c |
last_resource_update = 0;
|
|
rpm-build |
3ee90c |
trigger_fsa(fsa_source);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static int
|
|
rpm-build |
3ee90c |
do_update_resource(const char *node_name, lrmd_rsc_info_t * rsc, lrmd_event_data_t * op)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
/*
|
|
rpm-build |
3ee90c |
<status>
|
|
rpm-build |
3ee90c |
<nodes_status id=uname>
|
|
rpm-build |
3ee90c |
<lrm>
|
|
rpm-build |
3ee90c |
<lrm_resources>
|
|
rpm-build |
3ee90c |
<lrm_resource id=...>
|
|
rpm-build |
3ee90c |
</...>
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int rc = pcmk_ok;
|
|
rpm-build |
3ee90c |
xmlNode *update, *iter = NULL;
|
|
rpm-build |
3ee90c |
int call_opt = crmd_cib_smart_opt();
|
|
rpm-build |
3ee90c |
const char *uuid = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(op != NULL, return 0);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
iter = create_xml_node(iter, XML_CIB_TAG_STATUS);
|
|
rpm-build |
3ee90c |
update = iter;
|
|
rpm-build |
3ee90c |
iter = create_xml_node(iter, XML_CIB_TAG_STATE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (safe_str_eq(node_name, fsa_our_uname)) {
|
|
rpm-build |
3ee90c |
uuid = fsa_our_uuid;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
/* remote nodes uuid and uname are equal */
|
|
rpm-build |
3ee90c |
uuid = node_name;
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_NODE_IS_REMOTE, "true");
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_LOG_ASSERT(uuid != NULL);
|
|
rpm-build |
3ee90c |
if(uuid == NULL) {
|
|
rpm-build |
3ee90c |
rc = -EINVAL;
|
|
rpm-build |
3ee90c |
goto done;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_ATTR_UUID, uuid);
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_ATTR_UNAME, node_name);
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_ATTR_ORIGIN, __FUNCTION__);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
iter = create_xml_node(iter, XML_CIB_TAG_LRM);
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_ATTR_ID, uuid);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
iter = create_xml_node(iter, XML_LRM_TAG_RESOURCES);
|
|
rpm-build |
3ee90c |
iter = create_xml_node(iter, XML_LRM_TAG_RESOURCE);
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_ATTR_ID, op->rsc_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
build_operation_update(iter, rsc, op, node_name, __FUNCTION__);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (rsc) {
|
|
rpm-build |
3ee90c |
const char *container = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_ATTR_TYPE, rsc->type);
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_AGENT_ATTR_CLASS, rsc->standard);
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_AGENT_ATTR_PROVIDER, rsc->provider);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->params) {
|
|
rpm-build |
3ee90c |
container = g_hash_table_lookup(op->params, CRM_META"_"XML_RSC_ATTR_CONTAINER);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
if (container) {
|
|
rpm-build |
3ee90c |
crm_trace("Resource %s is a part of container resource %s", op->rsc_id, container);
|
|
rpm-build |
3ee90c |
crm_xml_add(iter, XML_RSC_ATTR_CONTAINER, container);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_warn("Resource %s no longer exists in the executor", op->rsc_id);
|
|
rpm-build |
3ee90c |
send_direct_ack(NULL, NULL, rsc, op, op->rsc_id);
|
|
rpm-build |
3ee90c |
goto cleanup;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
crm_log_xml_trace(update, __FUNCTION__);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* make it an asynchronous call and be done with it
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* Best case:
|
|
rpm-build |
3ee90c |
* the resource state will be discovered during
|
|
rpm-build |
3ee90c |
* the next signup or election.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* Bad case:
|
|
rpm-build |
3ee90c |
* we are shutting down and there is no DC at the time,
|
|
rpm-build |
3ee90c |
* but then why were we shutting down then anyway?
|
|
rpm-build |
3ee90c |
* (probably because of an internal error)
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* Worst case:
|
|
rpm-build |
3ee90c |
* we get shot for having resources "running" that really weren't
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* the alternative however means blocking here for too long, which
|
|
rpm-build |
3ee90c |
* isn't acceptable
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
fsa_cib_update(XML_CIB_TAG_STATUS, update, call_opt, rc, NULL);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (rc > 0) {
|
|
rpm-build |
3ee90c |
last_resource_update = rc;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
done:
|
|
rpm-build |
3ee90c |
/* the return code is a call number, not an error code */
|
|
rpm-build |
3ee90c |
crm_trace("Sent resource state update message: %d for %s=%u on %s",
|
|
rpm-build |
3ee90c |
rc, op->op_type, op->interval_ms, op->rsc_id);
|
|
rpm-build |
3ee90c |
fsa_register_cib_callback(rc, FALSE, NULL, cib_rsc_callback);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
cleanup:
|
|
rpm-build |
3ee90c |
free_xml(update);
|
|
rpm-build |
3ee90c |
return rc;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
void
|
|
rpm-build |
3ee90c |
do_lrm_event(long long action,
|
|
rpm-build |
3ee90c |
enum crmd_fsa_cause cause,
|
|
rpm-build |
3ee90c |
enum crmd_fsa_state cur_state, enum crmd_fsa_input cur_input, fsa_data_t * msg_data)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
CRM_CHECK(FALSE, return);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static char *
|
|
rpm-build |
3ee90c |
unescape_newlines(const char *string)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
char *pch = NULL;
|
|
rpm-build |
3ee90c |
char *ret = NULL;
|
|
rpm-build |
3ee90c |
static const char *escaped_newline = "\\n";
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (!string) {
|
|
rpm-build |
3ee90c |
return NULL;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
ret = strdup(string);
|
|
rpm-build |
3ee90c |
pch = strstr(ret, escaped_newline);
|
|
rpm-build |
3ee90c |
while (pch != NULL) {
|
|
rpm-build |
3ee90c |
/* Replace newline escape pattern with actual newline (and a space so we
|
|
rpm-build |
3ee90c |
* don't have to shuffle the rest of the buffer)
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
pch[0] = '\n';
|
|
rpm-build |
3ee90c |
pch[1] = ' ';
|
|
rpm-build |
3ee90c |
pch = strstr(pch, escaped_newline);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return ret;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static bool
|
|
rpm-build |
3ee90c |
did_lrm_rsc_op_fail(lrm_state_t *lrm_state, const char * rsc_id,
|
|
rpm-build |
3ee90c |
const char * op_type, guint interval_ms)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
rsc_history_t *entry = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(lrm_state != NULL, return FALSE);
|
|
rpm-build |
3ee90c |
CRM_CHECK(rsc_id != NULL, return FALSE);
|
|
rpm-build |
3ee90c |
CRM_CHECK(op_type != NULL, return FALSE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
entry = g_hash_table_lookup(lrm_state->resource_history, rsc_id);
|
|
rpm-build |
3ee90c |
if (entry == NULL || entry->failed == NULL) {
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (crm_str_eq(entry->failed->rsc_id, rsc_id, TRUE)
|
|
rpm-build |
3ee90c |
&& safe_str_eq(entry->failed->op_type, op_type)
|
|
rpm-build |
3ee90c |
&& entry->failed->interval_ms == interval_ms) {
|
|
rpm-build |
3ee90c |
return TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
return FALSE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
void
|
|
rpm-build |
3ee90c |
process_lrm_event(lrm_state_t *lrm_state, lrmd_event_data_t *op,
|
|
|
2e9006 |
active_op_t *pending, xmlNode *action_xml)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
char *op_id = NULL;
|
|
rpm-build |
3ee90c |
char *op_key = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
int update_id = 0;
|
|
rpm-build |
3ee90c |
gboolean remove = FALSE;
|
|
rpm-build |
3ee90c |
gboolean removed = FALSE;
|
|
rpm-build |
3ee90c |
bool need_direct_ack = FALSE;
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *rsc = NULL;
|
|
rpm-build |
3ee90c |
const char *node_name = NULL;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
CRM_CHECK(op != NULL, return);
|
|
rpm-build |
3ee90c |
CRM_CHECK(op->rsc_id != NULL, return);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// Remap new status codes for older DCs
|
|
rpm-build |
3ee90c |
if (compare_version(fsa_our_dc_version, "3.2.0") < 0) {
|
|
rpm-build |
3ee90c |
switch (op->op_status) {
|
|
rpm-build |
3ee90c |
case PCMK_LRM_OP_NOT_CONNECTED:
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_ERROR;
|
|
rpm-build |
3ee90c |
op->rc = PCMK_OCF_CONNECTION_DIED;
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
case PCMK_LRM_OP_INVALID:
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_ERROR;
|
|
rpm-build |
3ee90c |
op->rc = CRM_DIRECT_NACK_RC;
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
default:
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
op_id = make_stop_id(op->rsc_id, op->call_id);
|
|
rpm-build |
3ee90c |
op_key = generate_op_key(op->rsc_id, op->op_type, op->interval_ms);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// Get resource info if available (from executor state or action XML)
|
|
rpm-build |
3ee90c |
if (lrm_state) {
|
|
rpm-build |
3ee90c |
rsc = lrm_state_get_rsc_info(lrm_state, op->rsc_id, 0);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
if ((rsc == NULL) && action_xml) {
|
|
rpm-build |
3ee90c |
xmlNode *xml = find_xml_node(action_xml, XML_CIB_TAG_RESOURCE, TRUE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
const char *standard = crm_element_value(xml, XML_AGENT_ATTR_CLASS);
|
|
rpm-build |
3ee90c |
const char *provider = crm_element_value(xml, XML_AGENT_ATTR_PROVIDER);
|
|
rpm-build |
3ee90c |
const char *type = crm_element_value(xml, XML_ATTR_TYPE);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (standard && type) {
|
|
rpm-build |
3ee90c |
crm_info("%s agent information not cached, using %s%s%s:%s from action XML",
|
|
rpm-build |
3ee90c |
op->rsc_id, standard,
|
|
rpm-build |
3ee90c |
(provider? ":" : ""), (provider? provider : ""), type);
|
|
rpm-build |
3ee90c |
rsc = lrmd_new_rsc_info(op->rsc_id, standard, provider, type);
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_err("Can't process %s result because %s agent information not cached or in XML",
|
|
rpm-build |
3ee90c |
op_key, op->rsc_id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
// Get node name if available (from executor state or action XML)
|
|
rpm-build |
3ee90c |
if (lrm_state) {
|
|
rpm-build |
3ee90c |
node_name = lrm_state->node_name;
|
|
rpm-build |
3ee90c |
} else if (action_xml) {
|
|
rpm-build |
3ee90c |
node_name = crm_element_value(action_xml, XML_LRM_ATTR_TARGET);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if(pending == NULL) {
|
|
rpm-build |
3ee90c |
remove = TRUE;
|
|
rpm-build |
3ee90c |
if (lrm_state) {
|
|
rpm-build |
3ee90c |
pending = g_hash_table_lookup(lrm_state->pending_ops, op_id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->op_status == PCMK_LRM_OP_ERROR) {
|
|
rpm-build |
3ee90c |
switch(op->rc) {
|
|
rpm-build |
3ee90c |
case PCMK_OCF_NOT_RUNNING:
|
|
rpm-build |
3ee90c |
case PCMK_OCF_RUNNING_MASTER:
|
|
rpm-build |
3ee90c |
case PCMK_OCF_DEGRADED:
|
|
rpm-build |
3ee90c |
case PCMK_OCF_DEGRADED_MASTER:
|
|
rpm-build |
3ee90c |
// Leave it to the TE/scheduler to decide if this is an error
|
|
rpm-build |
3ee90c |
op->op_status = PCMK_LRM_OP_DONE;
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
default:
|
|
rpm-build |
3ee90c |
/* Nothing to do */
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->op_status != PCMK_LRM_OP_CANCELLED) {
|
|
rpm-build |
3ee90c |
/* We might not record the result, so directly acknowledge it to the
|
|
rpm-build |
3ee90c |
* originator instead, so it doesn't time out waiting for the result
|
|
rpm-build |
3ee90c |
* (especially important if part of a transition).
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
need_direct_ack = TRUE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (controld_action_is_recordable(op->op_type)) {
|
|
rpm-build |
3ee90c |
if (node_name && rsc) {
|
|
rpm-build |
3ee90c |
// We should record the result, and happily, we can
|
|
rpm-build |
3ee90c |
update_id = do_update_resource(node_name, rsc, op);
|
|
rpm-build |
3ee90c |
need_direct_ack = FALSE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (op->rsc_deleted) {
|
|
rpm-build |
3ee90c |
/* We shouldn't record the result (likely the resource was
|
|
rpm-build |
3ee90c |
* refreshed, cleaned, or removed while this operation was
|
|
rpm-build |
3ee90c |
* in flight).
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
crm_notice("Not recording %s result in CIB because "
|
|
rpm-build |
3ee90c |
"resource information was removed since it was initiated",
|
|
rpm-build |
3ee90c |
op_key);
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
/* This shouldn't be possible; the executor didn't consider the
|
|
rpm-build |
3ee90c |
* resource deleted, but we couldn't find resource or node
|
|
rpm-build |
3ee90c |
* information.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
crm_err("Unable to record %s result in CIB: %s", op_key,
|
|
rpm-build |
3ee90c |
(node_name? "No resource information" : "No node name"));
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (op->interval_ms == 0) {
|
|
rpm-build |
3ee90c |
/* A non-recurring operation was cancelled. Most likely, the
|
|
rpm-build |
3ee90c |
* never-initiated action was removed from the executor's pending
|
|
rpm-build |
3ee90c |
* operations list upon resource removal.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
need_direct_ack = TRUE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (pending == NULL) {
|
|
rpm-build |
3ee90c |
/* This recurring operation was cancelled, but was not pending. No
|
|
rpm-build |
3ee90c |
* transition actions are waiting on it, nothing needs to be done.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (op->user_data == NULL) {
|
|
rpm-build |
3ee90c |
/* This recurring operation was cancelled and pending, but we don't
|
|
rpm-build |
3ee90c |
* have a transition key. This should never happen.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
crm_err("Recurring operation %s was cancelled without transition information",
|
|
rpm-build |
3ee90c |
op_key);
|
|
rpm-build |
3ee90c |
|
|
|
91c557 |
} else if (is_set(pending->flags, active_op_remove)) {
|
|
rpm-build |
3ee90c |
/* This recurring operation was cancelled (by us) and pending, and we
|
|
rpm-build |
3ee90c |
* have been waiting for it to finish.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
if (lrm_state) {
|
|
rpm-build |
3ee90c |
erase_lrm_history_by_op(lrm_state, op);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* If the recurring operation had failed, the lrm_rsc_op is recorded as
|
|
rpm-build |
3ee90c |
* "last_failure" which won't get erased from the cib given the logic on
|
|
rpm-build |
3ee90c |
* purpose in erase_lrm_history_by_op(). So that the cancel action won't
|
|
rpm-build |
3ee90c |
* have a chance to get confirmed by DC with process_op_deletion().
|
|
rpm-build |
3ee90c |
* Cluster transition would get stuck waiting for the remaining action
|
|
rpm-build |
3ee90c |
* timer to time out.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* Directly acknowledge the cancel operation in this case.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
if (did_lrm_rsc_op_fail(lrm_state, pending->rsc_id,
|
|
rpm-build |
3ee90c |
pending->op_type, pending->interval_ms)) {
|
|
rpm-build |
3ee90c |
need_direct_ack = TRUE;
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (op->rsc_deleted) {
|
|
rpm-build |
3ee90c |
/* This recurring operation was cancelled (but not by us, and the
|
|
rpm-build |
3ee90c |
* executor does not have resource information, likely due to resource
|
|
rpm-build |
3ee90c |
* cleanup, refresh, or removal) and pending.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
crm_debug("Recurring op %s was cancelled due to resource deletion",
|
|
rpm-build |
3ee90c |
op_key);
|
|
rpm-build |
3ee90c |
need_direct_ack = TRUE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
/* This recurring operation was cancelled (but not by us, likely by the
|
|
rpm-build |
3ee90c |
* executor before stopping the resource) and pending. We don't need to
|
|
rpm-build |
3ee90c |
* do anything special.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (need_direct_ack) {
|
|
rpm-build |
3ee90c |
send_direct_ack(NULL, NULL, NULL, op, op->rsc_id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if(remove == FALSE) {
|
|
rpm-build |
3ee90c |
/* The caller will do this afterwards, but keep the logging consistent */
|
|
rpm-build |
3ee90c |
removed = TRUE;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} else if (lrm_state && ((op->interval_ms == 0)
|
|
rpm-build |
3ee90c |
|| (op->op_status == PCMK_LRM_OP_CANCELLED))) {
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
gboolean found = g_hash_table_remove(lrm_state->pending_ops, op_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->interval_ms != 0) {
|
|
rpm-build |
3ee90c |
removed = TRUE;
|
|
rpm-build |
3ee90c |
} else if (found) {
|
|
rpm-build |
3ee90c |
removed = TRUE;
|
|
rpm-build |
3ee90c |
crm_trace("Op %s (call=%d, stop-id=%s, remaining=%u): Confirmed",
|
|
rpm-build |
3ee90c |
op_key, op->call_id, op_id,
|
|
rpm-build |
3ee90c |
g_hash_table_size(lrm_state->pending_ops));
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (node_name == NULL) {
|
|
rpm-build |
3ee90c |
node_name = "unknown node"; // for logging
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
switch (op->op_status) {
|
|
rpm-build |
3ee90c |
case PCMK_LRM_OP_CANCELLED:
|
|
rpm-build |
3ee90c |
crm_info("Result of %s operation for %s on %s: %s "
|
|
rpm-build |
3ee90c |
CRM_XS " call=%d key=%s confirmed=%s",
|
|
rpm-build |
3ee90c |
crm_action_str(op->op_type, op->interval_ms),
|
|
rpm-build |
3ee90c |
op->rsc_id, node_name,
|
|
rpm-build |
3ee90c |
services_lrm_status_str(op->op_status),
|
|
rpm-build |
3ee90c |
op->call_id, op_key, (removed? "true" : "false"));
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
case PCMK_LRM_OP_DONE:
|
|
rpm-build |
3ee90c |
crm_notice("Result of %s operation for %s on %s: %d (%s) "
|
|
rpm-build |
3ee90c |
CRM_XS " call=%d key=%s confirmed=%s cib-update=%d",
|
|
rpm-build |
3ee90c |
crm_action_str(op->op_type, op->interval_ms),
|
|
rpm-build |
3ee90c |
op->rsc_id, node_name,
|
|
rpm-build |
3ee90c |
op->rc, services_ocf_exitcode_str(op->rc),
|
|
rpm-build |
3ee90c |
op->call_id, op_key, (removed? "true" : "false"),
|
|
rpm-build |
3ee90c |
update_id);
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
case PCMK_LRM_OP_TIMEOUT:
|
|
rpm-build |
3ee90c |
crm_err("Result of %s operation for %s on %s: %s "
|
|
rpm-build |
3ee90c |
CRM_XS " call=%d key=%s timeout=%dms",
|
|
rpm-build |
3ee90c |
crm_action_str(op->op_type, op->interval_ms),
|
|
rpm-build |
3ee90c |
op->rsc_id, node_name,
|
|
rpm-build |
3ee90c |
services_lrm_status_str(op->op_status),
|
|
rpm-build |
3ee90c |
op->call_id, op_key, op->timeout);
|
|
rpm-build |
3ee90c |
break;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
default:
|
|
rpm-build |
3ee90c |
crm_err("Result of %s operation for %s on %s: %s "
|
|
rpm-build |
3ee90c |
CRM_XS " call=%d key=%s confirmed=%s status=%d cib-update=%d",
|
|
rpm-build |
3ee90c |
crm_action_str(op->op_type, op->interval_ms),
|
|
rpm-build |
3ee90c |
op->rsc_id, node_name,
|
|
rpm-build |
3ee90c |
services_lrm_status_str(op->op_status), op->call_id, op_key,
|
|
rpm-build |
3ee90c |
(removed? "true" : "false"), op->op_status, update_id);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->output) {
|
|
rpm-build |
3ee90c |
char *prefix =
|
|
rpm-build |
3ee90c |
crm_strdup_printf("%s-" CRM_OP_FMT ":%d", node_name,
|
|
rpm-build |
3ee90c |
op->rsc_id, op->op_type, op->interval_ms,
|
|
rpm-build |
3ee90c |
op->call_id);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->rc) {
|
|
rpm-build |
3ee90c |
crm_log_output(LOG_NOTICE, prefix, op->output);
|
|
rpm-build |
3ee90c |
} else {
|
|
rpm-build |
3ee90c |
crm_log_output(LOG_DEBUG, prefix, op->output);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
free(prefix);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (lrm_state) {
|
|
rpm-build |
3ee90c |
if (safe_str_neq(op->op_type, RSC_METADATA)) {
|
|
rpm-build |
3ee90c |
crmd_alert_resource_op(lrm_state->node_name, op);
|
|
rpm-build |
3ee90c |
} else if (rsc && (op->rc == PCMK_OCF_OK)) {
|
|
rpm-build |
3ee90c |
char *metadata = unescape_newlines(op->output);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
metadata_cache_update(lrm_state->metadata_cache, rsc, metadata);
|
|
rpm-build |
3ee90c |
free(metadata);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
if (op->rsc_deleted) {
|
|
rpm-build |
3ee90c |
crm_info("Deletion of resource '%s' complete after %s", op->rsc_id, op_key);
|
|
rpm-build |
3ee90c |
if (lrm_state) {
|
|
rpm-build |
3ee90c |
delete_rsc_entry(lrm_state, NULL, op->rsc_id, NULL, pcmk_ok, NULL);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* If a shutdown was escalated while operations were pending,
|
|
rpm-build |
3ee90c |
* then the FSA will be stalled right now... allow it to continue
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
mainloop_set_trigger(fsa_source);
|
|
rpm-build |
3ee90c |
if (lrm_state && rsc) {
|
|
rpm-build |
3ee90c |
update_history_cache(lrm_state, rsc, op);
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
lrmd_free_rsc_info(rsc);
|
|
rpm-build |
3ee90c |
free(op_key);
|
|
rpm-build |
3ee90c |
free(op_id);
|
|
rpm-build |
3ee90c |
}
|