Skip to content
Merged
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
15 changes: 15 additions & 0 deletions crmsh/sbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,21 @@ def adjust_sbd_timeout_related_cluster_configuration(cls):
cls_inst.adjust_stonith_timeout()
cls_inst.adjust_systemd_start_timeout()

@staticmethod
def able_to_set_stonith_watchdog_timeout(value: int) -> bool:
'''
Check if able to set stonith-watchdog-timeout property
'''
if not ServiceManager().service_is_active("sbd.service"):
logger.error("Can't set stonith-watchdog-timeout because sbd.service is not active")
return False
sbd_watchdog_timeout = SBDTimeout.get_sbd_watchdog_timeout()
if value < sbd_watchdog_timeout:
logger.error("Can't set stonith-watchdog-timeout to %d because it is less than SBD_WATCHDOG_TIMEOUT(now: %d)",
value, sbd_watchdog_timeout)
return False
return True


class SBDManager(object):
"""
Expand Down
16 changes: 16 additions & 0 deletions crmsh/xmlutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,29 @@ def read_cib(fun, params=None):
def sanity_check_nvpairs(ident, node, attr_list):
rc = utils.VerifyResult.SUCCESS
for nvpair in node.iterchildren("nvpair"):
rc |= check_stonith_watchdog_timeout(nvpair)
n = nvpair.get("name")
if n and n not in attr_list:
logger.warning("%s: unknown attribute '%s'", ident, n)
rc |= utils.VerifyResult.WARNING
return rc


def check_stonith_watchdog_timeout(nvpair):
rc = utils.VerifyResult.SUCCESS
name, value = nvpair.get("name"), nvpair.get("value")
if name and name == "stonith-watchdog-timeout" and value:
try:
from . import sbd
intval = int(value)
if not sbd.SBDTimeout.able_to_set_stonith_watchdog_timeout(intval):
rc = utils.VerifyResult.FATAL_ERROR
except ValueError:
logger.error("stonith-watchdog-timeout must be an integer")
rc = utils.VerifyResult.FATAL_ERROR
return rc


def sanity_check_meta(ident, node, attr_list):
rc = utils.VerifyResult.SUCCESS
if node is None or not attr_list:
Expand Down
3 changes: 3 additions & 0 deletions test/features/bootstrap_sbd_delay.feature
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ Feature: configure sbd delay start correctly
And SBD option "SBD_WATCHDOG_TIMEOUT" value is "15"
And Cluster property "stonith-timeout" is "71"

When Try "crm configure property stonith-watchdog-timeout=1" on "hanode1"
Then Except "Can't set stonith-watchdog-timeout to 1 because it is less than SBD_WATCHDOG_TIMEOUT(now: 15)" in stderr

@clean
Scenario: disk-based SBD with big sbd_watchdog_timeout
When Run "sed -i 's/watchdog_timeout: 15/watchdog_timeout: 60/' /etc/crm/profiles.yml" on "hanode1"
Expand Down
8 changes: 8 additions & 0 deletions test/features/configure_bugs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,11 @@ Feature: Functional test for configure sub level
Then Cluster service is "started" on "hanode1"
When Run "crm node attribute hanode1 set cpu 2" on "hanode1"
Then Run "crm -F configure filter "sed 's/cpu=/#cpu='/g"" OK on "hanode1"

@clean
Scenario: Set stonith-watchdog-timeout when sbd.service is disactive
Given Cluster service is "stopped" on "hanode1"
When Run "crm cluster init -y" on "hanode1"
Then Cluster service is "started" on "hanode1"
When Try "crm configure property stonith-watchdog-timeout=20" on "hanode1"
Then Except "Can't set stonith-watchdog-timeout because sbd.service is not active" in stderr