@@ -272,79 +272,53 @@ def _parse_args(self, args: tuple[str, ...]) -> dict[str, int|str]:
272
272
logger .debug ("Parsed arguments: %s" , parameter_dict )
273
273
return parameter_dict
274
274
275
- @staticmethod
276
- def _adjust_timeout_dict (timeout_dict : dict ) -> dict :
277
- watchdog_timeout = timeout_dict .get ("watchdog" )
278
- msgwait_timeout = timeout_dict .get ("msgwait" )
279
- if watchdog_timeout and msgwait_timeout and msgwait_timeout < 2 * watchdog_timeout :
280
- logger .warning ("It's recommended to set msgwait timeout >= 2*watchdog timeout" )
281
- return timeout_dict
282
- if watchdog_timeout and not msgwait_timeout :
283
- timeout_dict ["msgwait" ] = 2 * watchdog_timeout
284
- logger .info ("No msgwait timeout specified, use 2*watchdog timeout: %s" , 2 * watchdog_timeout )
285
- return timeout_dict
286
- if msgwait_timeout and not watchdog_timeout :
287
- watchdog_timeout = msgwait_timeout // 2
288
- timeout_dict ["watchdog" ] = watchdog_timeout
289
- logger .info ("No watchdog timeout specified, use msgwait timeout/2: %s" , watchdog_timeout )
290
- return timeout_dict
291
- return timeout_dict
292
-
293
- def _configure_crashdump_watchdog (self , timeout : int ) -> bool :
294
- def set_crashdump_option () -> bool :
295
- shell = sh .LocalShell ()
296
- cib = xmlutil .text2elem (shell .get_stdout_or_raise_error (None , 'crm configure show xml' ))
297
- ra = cibquery .ResourceAgent ("stonith" , "" , "fence_sbd" )
298
- res_id_list = cibquery .has_primitive (cib , ra )
299
- if not res_id_list :
300
- logger .error ("No fence_sbd resource found" )
301
- return False
302
- crashdump_value = cibquery .get_parameter_value (cib , res_id_list [0 ], "crashdump" )
303
- if utils .is_boolean_false (crashdump_value ):
304
- cmd = f"crm resource param { res_id_list [0 ]} set crashdump 1"
305
- shell .get_stdout_or_raise_error (None , cmd )
306
- logger .info ("Set crashdump option for fence_sbd resource" )
307
- return True
308
-
309
- finished = True
310
- logger .info ("Configure crashdump watchdog timeout" )
311
-
312
- for node in self .cluster_nodes :
313
- if not self .service_manager .service_is_active ("kdump" , node ):
314
- logger .error ("kdump service is not active on %s" , node )
315
- return not finished
316
-
317
- update_dict = {"SBD_TIMEOUT_ACTION" : "flush,crashdump" }
318
- if sbd .SBDUtils .is_using_disk_based_sbd ():
319
- if not set_crashdump_option ():
320
- return not finished
321
- update_dict ["SBD_OPTS" ] = f"-C { timeout } "
322
- elif sbd .SBDUtils .is_using_diskless_sbd ():
323
- update_dict ["SBD_OPTS" ] = f"-C { timeout } -Z"
324
- sbd .SBDManager .update_sbd_configuration (update_dict )
325
-
326
- return finished
275
+ def set_crashdump_option (self ):
276
+ '''
277
+ Set crashdump option for fence_sbd resource
278
+ '''
279
+ shell = sh .LocalShell ()
280
+ cib = xmlutil .text2elem (shell .get_stdout_or_raise_error (None , 'crm configure show xml' ))
281
+ ra = cibquery .ResourceAgent ("stonith" , "" , "fence_sbd" )
282
+ res_id_list = cibquery .has_primitive (cib , ra )
283
+ if not res_id_list :
284
+ logger .error ("No fence_sbd resource found" )
285
+ return
286
+ crashdump_value = cibquery .get_parameter_value (cib , res_id_list [0 ], "crashdump" )
287
+ if utils .is_boolean_false (crashdump_value ):
288
+ cmd = f"crm resource param { res_id_list [0 ]} set crashdump 1"
289
+ shell .get_stdout_or_raise_error (None , cmd )
290
+ logger .info ("Set crashdump option for fence_sbd resource" )
327
291
328
292
def _configure_diskbase (self , parameter_dict : dict ):
329
293
'''
330
294
Configure disk-based SBD based on input parameters and runtime config
331
295
'''
332
296
update_dict = {}
297
+ timeout_dict = {
298
+ item : parameter_dict .get (item ) or self .device_meta_dict_runtime .get (item )
299
+ for item in self .TIMEOUT_TYPES if item != "crashdump-watchdog"
300
+ }
301
+
302
+ crashdump_watchdog_timeout = parameter_dict .get ("crashdump-watchdog" )
303
+ if crashdump_watchdog_timeout :
304
+ self .set_crashdump_option ()
305
+ timeout_dict ["msgwait" ] = 2 * timeout_dict ["watchdog" ] + crashdump_watchdog_timeout
306
+ logger .info ("Set msgwait timeout to 2*watchdog + crashdump-watchdog: %s" , timeout_dict ["msgwait" ])
307
+ update_dict ["SBD_TIMEOUT_ACTION" ] = "flush,crashdump"
308
+ update_dict ["SBD_OPTS" ] = f"-C { crashdump_watchdog_timeout } "
309
+
310
+ if timeout_dict ["msgwait" ] < 2 * timeout_dict ["watchdog" ]:
311
+ logger .warning ("It's recommended to set msgwait timeout >= 2*watchdog timeout" )
312
+ return
313
+
333
314
watchdog_device = parameter_dict .get ("watchdog-device" )
334
315
if watchdog_device != self .watchdog_device_from_config :
335
316
update_dict ["SBD_WATCHDOG_DEV" ] = watchdog_device
336
- timeout_dict = {k : v for k , v in parameter_dict .items () if k in self .TIMEOUT_TYPES }
337
- is_subdict_timeout = utils .is_subdict (timeout_dict , self .device_meta_dict_runtime )
338
317
339
- if is_subdict_timeout and not update_dict :
340
- logger .info ("No metadata of SBD device changed " )
318
+ if timeout_dict == self . device_meta_dict_runtime and not update_dict :
319
+ logger .info ("No change in SBD configuration " )
341
320
return
342
321
343
- if not is_subdict_timeout :
344
- timeout_dict = self ._adjust_timeout_dict (timeout_dict )
345
- # merge runtime timeout dict into parameter timeout dict without overwriting
346
- timeout_dict = {** self .device_meta_dict_runtime , ** timeout_dict }
347
-
348
322
sbd_manager = sbd .SBDManager (
349
323
device_list_to_init = self .device_list_from_config ,
350
324
timeout_dict = timeout_dict ,
@@ -363,6 +337,10 @@ def _configure_diskless(self, parameter_dict: dict):
363
337
watchdog_device = parameter_dict .get ("watchdog-device" )
364
338
if watchdog_device != self .watchdog_device_from_config :
365
339
update_dict ["SBD_WATCHDOG_DEV" ] = watchdog_device
340
+ crashdump_watchdog_timeout = parameter_dict .get ("crashdump-watchdog" )
341
+ if crashdump_watchdog_timeout :
342
+ update_dict ["SBD_TIMEOUT_ACTION" ] = "flush,crashdump"
343
+ update_dict ["SBD_OPTS" ] = f"-C { crashdump_watchdog_timeout } -Z"
366
344
if not update_dict :
367
345
logger .info ("No change in SBD configuration" )
368
346
return
@@ -465,14 +443,10 @@ def do_configure(self, context, *args) -> bool:
465
443
return True
466
444
467
445
parameter_dict = self ._parse_args (args )
468
- crashdump_watchdog_timeout = parameter_dict .pop ("crashdump-watchdog" , None )
469
446
if sbd .SBDUtils .is_using_disk_based_sbd ():
470
447
self ._configure_diskbase (parameter_dict )
471
448
elif sbd .SBDUtils .is_using_diskless_sbd ():
472
449
self ._configure_diskless (parameter_dict )
473
- if crashdump_watchdog_timeout :
474
- if not self ._configure_crashdump_watchdog (crashdump_watchdog_timeout ):
475
- return False
476
450
return True
477
451
478
452
except self .SyntaxError as e :
0 commit comments