From 6a6e4ed482d5527e57967e9a4b177145dab98f84 Mon Sep 17 00:00:00 2001 From: xin liang Date: Tue, 23 Sep 2025 22:36:07 +0800 Subject: [PATCH 1/2] Fix: ui_configure: Check if able to set stonith-watchdog-timeout property --- crmsh/sbd.py | 15 +++++++++++++++ crmsh/xmlutil.py | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/crmsh/sbd.py b/crmsh/sbd.py index 425653d25..8f27dcd0c 100644 --- a/crmsh/sbd.py +++ b/crmsh/sbd.py @@ -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): """ diff --git a/crmsh/xmlutil.py b/crmsh/xmlutil.py index f03058cd2..df9968c37 100644 --- a/crmsh/xmlutil.py +++ b/crmsh/xmlutil.py @@ -158,6 +158,7 @@ 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) @@ -165,6 +166,21 @@ def sanity_check_nvpairs(ident, node, attr_list): 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: From 1ef30dd1015be0d7da0433fc2d3f90b6ae228272 Mon Sep 17 00:00:00 2001 From: xin liang Date: Thu, 25 Sep 2025 22:45:47 +0800 Subject: [PATCH 2/2] Dev: behave: Adjust functional test for previous commit --- test/features/bootstrap_sbd_delay.feature | 3 +++ test/features/configure_bugs.feature | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/test/features/bootstrap_sbd_delay.feature b/test/features/bootstrap_sbd_delay.feature index 8d5d104a1..9b84ad600 100644 --- a/test/features/bootstrap_sbd_delay.feature +++ b/test/features/bootstrap_sbd_delay.feature @@ -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" diff --git a/test/features/configure_bugs.feature b/test/features/configure_bugs.feature index 76810e12d..23f68d4e2 100644 --- a/test/features/configure_bugs.feature +++ b/test/features/configure_bugs.feature @@ -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