Skip to content

Commit 10de2e7

Browse files
committed
Feature: fencer: requested fencing delay combines with any delays from pcmk_delay_base/max
Requested fencing delay doesn't take precedence over any configured pcmk_delay_base/max. A delay value -1 now means disable also any static/random fencing delays from pcmk_delay_base/max. It's not used by any consumers for now.
1 parent b56cfaa commit 10de2e7

File tree

5 files changed

+38
-45
lines changed

5 files changed

+38
-45
lines changed

daemons/fenced/fenced_commands.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ create_async_command(xmlNode * msg)
241241
crm_element_value_int(msg, F_STONITH_CALLOPTS, &(cmd->options));
242242
crm_element_value_int(msg, F_STONITH_TIMEOUT, &(cmd->default_timeout));
243243
cmd->timeout = cmd->default_timeout;
244-
// Default value -1 means no enforced fencing delay
245-
cmd->start_delay = -1;
244+
// Value -1 means disable any static/random fencing delays
246245
crm_element_value_int(msg, F_STONITH_DELAY, &(cmd->start_delay));
247246

248247
cmd->origin = crm_element_value_copy(msg, F_ORIG);
@@ -465,7 +464,7 @@ schedule_stonith_command(async_command_t * cmd, stonith_device_t * device)
465464
{
466465
int delay_max = 0;
467466
int delay_base = 0;
468-
bool delay_enforced = (cmd->start_delay >= 0);
467+
int requested_delay = cmd->start_delay;
469468

470469
CRM_CHECK(cmd != NULL, return);
471470
CRM_CHECK(device != NULL, return);
@@ -498,35 +497,36 @@ schedule_stonith_command(async_command_t * cmd, stonith_device_t * device)
498497
device->pending_ops = g_list_append(device->pending_ops, cmd);
499498
mainloop_set_trigger(device->work);
500499

501-
// No enforced fencing delay
502-
if (delay_enforced == FALSE) {
503-
delay_max = get_action_delay_max(device, cmd->action);
504-
delay_base = get_action_delay_base(device, cmd->action);
505-
if (delay_max == 0) {
506-
delay_max = delay_base;
507-
}
508-
if (delay_max < delay_base) {
509-
crm_warn("Base-delay (%ds) is larger than max-delay (%ds) "
510-
"for %s on %s - limiting to max-delay",
511-
delay_base, delay_max, cmd->action, device->id);
512-
delay_base = delay_max;
513-
}
514-
if (delay_max > 0) {
515-
// coverity[dont_call] We're not using rand() for security
516-
cmd->start_delay =
517-
((delay_max != delay_base)?(rand() % (delay_max - delay_base)):0)
518-
+ delay_base;
519-
}
500+
// Value -1 means disable any static/random fencing delays
501+
if (requested_delay < 0) {
502+
return;
503+
}
504+
505+
delay_max = get_action_delay_max(device, cmd->action);
506+
delay_base = get_action_delay_base(device, cmd->action);
507+
if (delay_max == 0) {
508+
delay_max = delay_base;
509+
}
510+
if (delay_max < delay_base) {
511+
crm_warn("Base-delay (%ds) is larger than max-delay (%ds) "
512+
"for %s on %s - limiting to max-delay",
513+
delay_base, delay_max, cmd->action, device->id);
514+
delay_base = delay_max;
515+
}
516+
if (delay_max > 0) {
517+
// coverity[dont_call] We're not using rand() for security
518+
cmd->start_delay +=
519+
((delay_max != delay_base)?(rand() % (delay_max - delay_base)):0)
520+
+ delay_base;
520521
}
521522

522523
if (cmd->start_delay > 0) {
523-
crm_notice("Delaying '%s' action%s%s on %s for %s%ds (timeout=%ds, base=%ds, "
524-
"max=%ds)",
524+
crm_notice("Delaying '%s' action%s%s on %s for %ds (timeout=%ds, "
525+
"requested_delay=%ds, base=%ds, max=%ds)",
525526
cmd->action,
526527
cmd->victim ? " targeting " : "", cmd->victim ? cmd->victim : "",
527-
device->id, delay_enforced ? "enforced " : "",
528-
cmd->start_delay, cmd->timeout,
529-
delay_base, delay_max);
528+
device->id, cmd->start_delay, cmd->timeout,
529+
requested_delay, delay_base, delay_max);
530530
cmd->delay_id =
531531
g_timeout_add_seconds(cmd->start_delay, start_delay_helper, cmd);
532532
}

daemons/fenced/fenced_remote.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ stonith_topology_next(remote_fencing_op_t * op)
842842
op->client_name, op->originator, op->id);
843843
set_op_device_list(op, tp->levels[op->level]);
844844

845-
// The enforced delay has been applied for the first fencing level
845+
// The requested delay has been applied for the first fencing level
846846
if (op->level > 1 && op->delay > 0) {
847847
op->delay = 0;
848848
}
@@ -1004,9 +1004,7 @@ create_remote_stonith_op(const char *client, xmlNode * request, gboolean peer)
10041004
op = calloc(1, sizeof(remote_fencing_op_t));
10051005

10061006
crm_element_value_int(request, F_STONITH_TIMEOUT, &(op->base_timeout));
1007-
1008-
// Default value -1 means no enforced fencing delay
1009-
op->delay = -1;
1007+
// Value -1 means disable any static/random fencing delays
10101008
crm_element_value_int(request, F_STONITH_DELAY, &(op->delay));
10111009

10121010
if (peer && dev) {
@@ -1458,7 +1456,7 @@ advance_op_topology(remote_fencing_op_t *op, const char *device, xmlNode *msg,
14581456
crm_trace("Next targeting %s on behalf of %s@%s (rc was %d)",
14591457
op->target, op->originator, op->client_name, rc);
14601458

1461-
// The enforced delay has been applied for the first device
1459+
// The requested delay has been applied for the first device
14621460
if (op->delay > 0) {
14631461
op->delay = 0;
14641462
}
@@ -1517,10 +1515,7 @@ call_remote_stonith(remote_fencing_op_t * op, st_query_result_t * peer)
15171515
crm_xml_add(remote_op, F_STONITH_CLIENTNAME, op->client_name);
15181516
crm_xml_add_int(remote_op, F_STONITH_TIMEOUT, timeout);
15191517
crm_xml_add_int(remote_op, F_STONITH_CALLOPTS, op->call_options);
1520-
1521-
if (op->delay >= 0) {
1522-
crm_xml_add_int(remote_op, F_STONITH_DELAY, op->delay);
1523-
}
1518+
crm_xml_add_int(remote_op, F_STONITH_DELAY, op->delay);
15241519

15251520
if (device) {
15261521
timeout_one = TIMEOUT_MULTIPLY_FACTOR *

daemons/fenced/pacemaker-fenced.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ typedef struct remote_fencing_op_s {
113113
* values associated with the devices this fencing operation may call */
114114
gint total_timeout;
115115

116-
/*! Enforced fencing delay.
117-
* Default value -1 means no enforced fencing delay. */
116+
/*! Requested fencing delay.
117+
* Value -1 means disable any static/random fencing delays. */
118118
int delay;
119119

120120
/*! Delegate is the node being asked to perform a fencing action

include/crm/stonith-ng.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ typedef struct stonith_api_operations_s
401401
char **error_output);
402402

403403
/*!
404-
* \brief Issue a fencing action against a node with enforced fencing delay.
404+
* \brief Issue a fencing action against a node with requested fencing delay.
405405
*
406406
* \note Possible actions are, 'on', 'off', and 'reboot'.
407407
*
@@ -411,7 +411,8 @@ typedef struct stonith_api_operations_s
411411
* \param action, The fencing action to take
412412
* \param timeout, The default per device timeout to use with each device
413413
* capable of fencing the target.
414-
* \param delay, Any enforced fencing delay. -1 to disable
414+
* \param delay, Apply a fencing delay. Value -1 means disable also any
415+
* static/random fencing delays from pcmk_delay_base/max
415416
*
416417
* \retval 0 success
417418
* \retval negative error code on failure.

lib/fencing/st_client.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,10 +1080,7 @@ stonith_api_fence_with_delay(stonith_t * stonith, int call_options, const char *
10801080
crm_xml_add(data, F_STONITH_ACTION, action);
10811081
crm_xml_add_int(data, F_STONITH_TIMEOUT, timeout);
10821082
crm_xml_add_int(data, F_STONITH_TOLERANCE, tolerance);
1083-
1084-
if (delay >= 0) {
1085-
crm_xml_add_int(data, F_STONITH_DELAY, delay);
1086-
}
1083+
crm_xml_add_int(data, F_STONITH_DELAY, delay);
10871084

10881085
rc = stonith_send_command(stonith, STONITH_OP_FENCE, data, NULL, call_options, timeout);
10891086
free_xml(data);
@@ -1096,7 +1093,7 @@ stonith_api_fence(stonith_t * stonith, int call_options, const char *node, const
10961093
int timeout, int tolerance)
10971094
{
10981095
return stonith_api_fence_with_delay(stonith, call_options, node, action,
1099-
timeout, tolerance, -1);
1096+
timeout, tolerance, 0);
11001097
}
11011098

11021099
static int

0 commit comments

Comments
 (0)