Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion daemons/controld/controld_fencing.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,13 +995,19 @@ void
controld_validate_fencing_watchdog_timeout(const char *value)
{
const char *our_nodename = controld_globals.cluster->priv->node_name;
long long timeout_ms = 0;

timeout_ms = pcmk__parse_fencing_watchdog_timeout(value);
if (timeout_ms == 0) {
return;
}

// Validate only if the timeout will be used
if ((fencer_api != NULL) && (fencer_api->state != stonith_disconnected)
&& stonith__watchdog_fencing_enabled_for_node_api(fencer_api,
our_nodename)) {

pcmk__valid_fencing_watchdog_timeout(value);
pcmk__valid_fencing_watchdog_timeout(timeout_ms);
}
}

Expand Down
4 changes: 3 additions & 1 deletion daemons/execd/execd_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ handle_check_request(pcmk__request_t *request)
xmlNode *wrapper = NULL;
xmlNode *data = NULL;
const char *timeout = NULL;
long long timeout_ms = 0;

if (!allowed) {
pcmk__set_result(&request->result, CRM_EX_INSUFFICIENT_PRIV,
Expand All @@ -158,7 +159,8 @@ handle_check_request(pcmk__request_t *request)
/* FIXME: This just exits on certain conditions, which seems like a pretty
* extreme reaction for a daemon to take.
*/
pcmk__valid_fencing_watchdog_timeout(timeout);
timeout_ms = pcmk__parse_fencing_watchdog_timeout(timeout);
pcmk__valid_fencing_watchdog_timeout(timeout_ms);

pcmk__set_result(&request->result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
return NULL;
Expand Down
12 changes: 1 addition & 11 deletions daemons/fenced/fenced_cib.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ get_fencing_watchdog_timeout(xmlNode *cib)
{
xmlNode *stonith_watchdog_xml = NULL;
const char *value = NULL;
int rc = pcmk_rc_ok;
long long timeout_ms = 0;

// @TODO An XPath search can't handle multiple instances or rules
stonith_watchdog_xml = pcmk__xpath_find_one(cib->doc,
Expand All @@ -182,16 +180,8 @@ get_fencing_watchdog_timeout(xmlNode *cib)
}

value = pcmk__xe_get(stonith_watchdog_xml, PCMK_XA_VALUE);
if (value == NULL) {
return 0;
}

rc = pcmk__parse_ms(value, &timeout_ms);
if ((rc == pcmk_rc_ok) && (timeout_ms >= 0)) {
return timeout_ms;
}

return pcmk__auto_fencing_watchdog_timeout();
return pcmk__parse_fencing_watchdog_timeout(value);;
}

/*!
Expand Down
4 changes: 2 additions & 2 deletions include/crm/common/options_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ bool pcmk__valid_placement_strategy(const char *value);
// from watchdog.c
long pcmk__get_sbd_watchdog_timeout(void);
bool pcmk__get_sbd_sync_resource_startup(void);
long pcmk__auto_fencing_watchdog_timeout(void);
bool pcmk__valid_fencing_watchdog_timeout(const char *value);
long long pcmk__parse_fencing_watchdog_timeout(const char *value);
bool pcmk__valid_fencing_watchdog_timeout(long long st_timeout);

// @COMPAT Deprecated cluster options
#define PCMK__OPT_CANCEL_REMOVED_ACTIONS "cancel-removed-actions"
Expand Down
26 changes: 15 additions & 11 deletions lib/common/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pcmk__get_sbd_sync_resource_startup(void)
}

// 0 <= return value <= min(LONG_MAX, (2 * SBD timeout))
long
static long
pcmk__auto_fencing_watchdog_timeout(void)
{
long sbd_timeout = pcmk__get_sbd_watchdog_timeout();
Expand All @@ -271,8 +271,8 @@ pcmk__auto_fencing_watchdog_timeout(void)
return (long) QB_MIN(st_timeout, LONG_MAX);
}

bool
pcmk__valid_fencing_watchdog_timeout(const char *value)
long long
pcmk__parse_fencing_watchdog_timeout(const char *value)
{
/* @COMPAT At a compatibility break, accept either negative values or a
* specific string like "auto" (but not both) to mean "auto-calculate the
Expand All @@ -293,15 +293,20 @@ pcmk__valid_fencing_watchdog_timeout(const char *value)
st_timeout, value);
}

return st_timeout;
}

bool
pcmk__valid_fencing_watchdog_timeout(long long st_timeout)
{
if (st_timeout == 0) {
pcmk__debug("Watchdog may be enabled but "
PCMK_OPT_FENCING_WATCHDOG_TIMEOUT " is disabled (%s)",
pcmk__s(value, "default"));
PCMK_OPT_FENCING_WATCHDOG_TIMEOUT " is disabled (%lldms)",
st_timeout);

} else if (pcmk__locate_sbd() == 0) {
pcmk__emerg("Shutting down: " PCMK_OPT_FENCING_WATCHDOG_TIMEOUT
" configured (%s) but SBD not active",
pcmk__s(value, "auto"));
" configured (%lldms) but SBD not active", st_timeout);
crm_exit(CRM_EX_FATAL);
return false;

Expand All @@ -313,14 +318,13 @@ pcmk__valid_fencing_watchdog_timeout(const char *value)
* parsable, positive, and less than the SBD_WATCHDOG_TIMEOUT
*/
pcmk__emerg("Shutting down: " PCMK_OPT_FENCING_WATCHDOG_TIMEOUT
" (%s) too short (must be >%ldms)",
value, sbd_timeout);
" (%lldms) too short (must be >%ldms)",
st_timeout, sbd_timeout);
crm_exit(CRM_EX_FATAL);
return false;
}
pcmk__info("Watchdog configured with " PCMK_OPT_FENCING_WATCHDOG_TIMEOUT
" %s and SBD timeout %ldms",
value, sbd_timeout);
" %lldms and SBD timeout %ldms", st_timeout, sbd_timeout);
}
return true;
}
4 changes: 3 additions & 1 deletion lib/lrmd/lrmd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,11 +1029,13 @@ lrmd__validate_remote_settings(lrmd_t *lrmd, GHashTable *hash)
const char *value;
lrmd_private_t *native = lrmd->lrmd_private;
xmlNode *data = pcmk__xe_create(NULL, PCMK__XA_LRMD_OP);
long long timeout_ms = 0;

pcmk__xe_set(data, PCMK__XA_LRMD_ORIGIN, __func__);

value = pcmk__cluster_option(hash, PCMK_OPT_FENCING_WATCHDOG_TIMEOUT);
if ((value) &&
timeout_ms = pcmk__parse_fencing_watchdog_timeout(value);
if ((timeout_ms != 0) &&
(stonith__watchdog_fencing_enabled_for_node(native->remote_nodename))) {
pcmk__xe_set(data, PCMK__XA_LRMD_WATCHDOG, value);
}
Expand Down