Skip to content

Commit 98a5ae1

Browse files
committed
Feature: fencer: any delays from pcmk_delay_base/max are added to requested fencing delay
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 69cc3f6 commit 98a5ae1

File tree

5 files changed

+38
-45
lines changed

5 files changed

+38
-45
lines changed

fencing/commands.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@ create_async_command(xmlNode * msg)
243243
crm_element_value_int(msg, F_STONITH_CALLOPTS, &(cmd->options));
244244
crm_element_value_int(msg, F_STONITH_TIMEOUT, &(cmd->default_timeout));
245245
cmd->timeout = cmd->default_timeout;
246-
// Default value -1 means no enforced fencing delay
247-
cmd->start_delay = -1;
246+
// Value -1 means disable any static/random fencing delays
248247
crm_element_value_int(msg, F_STONITH_DELAY, &(cmd->start_delay));
249248

250249
cmd->origin = crm_element_value_copy(msg, F_ORIG);
@@ -467,7 +466,7 @@ schedule_stonith_command(async_command_t * cmd, stonith_device_t * device)
467466
{
468467
int delay_max = 0;
469468
int delay_base = 0;
470-
bool delay_enforced = (cmd->start_delay >= 0);
469+
int requested_delay = cmd->start_delay;
471470

472471
CRM_CHECK(cmd != NULL, return);
473472
CRM_CHECK(device != NULL, return);
@@ -500,35 +499,36 @@ schedule_stonith_command(async_command_t * cmd, stonith_device_t * device)
500499
device->pending_ops = g_list_append(device->pending_ops, cmd);
501500
mainloop_set_trigger(device->work);
502501

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

524525
if (cmd->start_delay > 0) {
525-
crm_notice("Delaying '%s' action%s%s on %s for %s%ds (timeout=%ds, base=%ds, "
526-
"max=%ds)",
526+
crm_notice("Delaying '%s' action%s%s on %s for %ds (timeout=%ds, "
527+
"requested_delay=%ds, base=%ds, max=%ds)",
527528
cmd->action,
528529
cmd->victim ? " targeting " : "", cmd->victim ? cmd->victim : "",
529-
device->id, delay_enforced ? "enforced " : "",
530-
cmd->start_delay, cmd->timeout,
531-
delay_base, delay_max);
530+
device->id, cmd->start_delay, cmd->timeout,
531+
requested_delay, delay_base, delay_max);
532532
cmd->delay_id =
533533
g_timeout_add_seconds(cmd->start_delay, start_delay_helper, cmd);
534534
}

fencing/internal.h

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

101-
/*! Enforced fencing delay.
102-
* Default value -1 means no enforced fencing delay. */
101+
/*! Requested fencing delay.
102+
* Value -1 means disable any static/random fencing delays. */
103103
int delay;
104104

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

fencing/remote.c

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

838-
// The enforced delay has been applied for the first fencing level
838+
// The requested delay has been applied for the first fencing level
839839
if (op->level > 1 && op->delay > 0) {
840840
op->delay = 0;
841841
}
@@ -997,9 +997,7 @@ create_remote_stonith_op(const char *client, xmlNode * request, gboolean peer)
997997
op = calloc(1, sizeof(remote_fencing_op_t));
998998

999999
crm_element_value_int(request, F_STONITH_TIMEOUT, &(op->base_timeout));
1000-
1001-
// Default value -1 means no enforced fencing delay
1002-
op->delay = -1;
1000+
// Value -1 means disable any static/random fencing delays
10031001
crm_element_value_int(request, F_STONITH_DELAY, &(op->delay));
10041002

10051003
if (peer && dev) {
@@ -1450,7 +1448,7 @@ advance_op_topology(remote_fencing_op_t *op, const char *device, xmlNode *msg,
14501448
crm_trace("Next targeting %s on behalf of %s@%s (rc was %d)",
14511449
op->target, op->originator, op->client_name, rc);
14521450

1453-
// The enforced delay has been applied for the first device
1451+
// The requested delay has been applied for the first device
14541452
if (op->delay > 0) {
14551453
op->delay = 0;
14561454
}
@@ -1509,10 +1507,7 @@ call_remote_stonith(remote_fencing_op_t * op, st_query_result_t * peer)
15091507
crm_xml_add(remote_op, F_STONITH_CLIENTNAME, op->client_name);
15101508
crm_xml_add_int(remote_op, F_STONITH_TIMEOUT, timeout);
15111509
crm_xml_add_int(remote_op, F_STONITH_CALLOPTS, op->call_options);
1512-
1513-
if (op->delay >= 0) {
1514-
crm_xml_add_int(remote_op, F_STONITH_DELAY, op->delay);
1515-
}
1510+
crm_xml_add_int(remote_op, F_STONITH_DELAY, op->delay);
15161511

15171512
if (device) {
15181513
timeout_one = TIMEOUT_MULTIPLY_FACTOR *

include/crm/stonith-ng.h

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

407407
/*!
408-
* \brief Issue a fencing action against a node with enforced fencing delay.
408+
* \brief Issue a fencing action against a node with requested fencing delay.
409409
*
410410
* \note Possible actions are, 'on', 'off', and 'reboot'.
411411
*
@@ -415,7 +415,8 @@ typedef struct stonith_api_operations_s
415415
* \param action, The fencing action to take
416416
* \param timeout, The default per device timeout to use with each device
417417
* capable of fencing the target.
418-
* \param delay, Any enforced fencing delay. -1 to disable
418+
* \param delay, Apply a fencing delay. Value -1 means disable also any
419+
* static/random fencing delays from pcmk_delay_base/max
419420
*
420421
* \retval 0 success
421422
* \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
@@ -1189,10 +1189,7 @@ stonith_api_fence_with_delay(stonith_t * stonith, int call_options, const char *
11891189
crm_xml_add(data, F_STONITH_ACTION, action);
11901190
crm_xml_add_int(data, F_STONITH_TIMEOUT, timeout);
11911191
crm_xml_add_int(data, F_STONITH_TOLERANCE, tolerance);
1192-
1193-
if (delay >= 0) {
1194-
crm_xml_add_int(data, F_STONITH_DELAY, delay);
1195-
}
1192+
crm_xml_add_int(data, F_STONITH_DELAY, delay);
11961193

11971194
rc = stonith_send_command(stonith, STONITH_OP_FENCE, data, NULL, call_options, timeout);
11981195
free_xml(data);
@@ -1205,7 +1202,7 @@ stonith_api_fence(stonith_t * stonith, int call_options, const char *node, const
12051202
int timeout, int tolerance)
12061203
{
12071204
return stonith_api_fence_with_delay(stonith, call_options, node, action,
1208-
timeout, tolerance, -1);
1205+
timeout, tolerance, 0);
12091206
}
12101207

12111208
static int

0 commit comments

Comments
 (0)