@@ -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 }
0 commit comments