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
5 changes: 5 additions & 0 deletions crmsh/sbd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re
import typing
import shutil
from . import utils, sh
from . import bootstrap
from . import log
Expand Down Expand Up @@ -436,6 +437,7 @@
DISKLESS_SBD_MIN_EXPECTED_VOTE = 3
DISKLESS_SBD_WARNING = "Diskless SBD requires cluster with three or more nodes. If you want to use diskless SBD for 2-node cluster, should be combined with QDevice."
SBD_NOT_INSTALLED_MSG = "Package sbd is not installed."
FENCE_SBD_NOT_EXISTED_MSG = "fence_sbd command does not exist."
SBD_RA = "stonith:fence_sbd"
SBD_RA_ID = "stonith-sbd"
SBD_DEVICE_MAX = 3
Expand Down Expand Up @@ -522,6 +524,9 @@
else:
return

if not shutil.which("fence_sbd"):
utils.fatal(self.FENCE_SBD_NOT_EXISTED_MSG)

Check warning on line 528 in crmsh/sbd.py

View check run for this annotation

Codecov / codecov/patch

crmsh/sbd.py#L528

Added line #L528 was not covered by tests

opt_str = SBDManager.convert_timeout_dict_to_opt_str(self.timeout_dict)
shell = sh.cluster_shell()
for dev in self.device_list_to_init:
Expand Down
4 changes: 3 additions & 1 deletion test/unittests/test_sbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,10 @@ def test_initialize_sbd_diskless(self, mock_logger_info):
@patch('logging.Logger.debug')
@patch('crmsh.sbd.sh.cluster_shell')
@patch('crmsh.sbd.SBDManager.convert_timeout_dict_to_opt_str')
@patch('shutil.which')
@patch('logging.Logger.info')
def test_initialize_sbd_diskbased(self, mock_logger_info, mock_convert_timeout_dict_to_opt_str, mock_cluster_shell, mock_logger_debug, mock_ServiceManager):
def test_initialize_sbd_diskbased(self, mock_logger_info, mock_which, mock_convert_timeout_dict_to_opt_str, mock_cluster_shell, mock_logger_debug, mock_ServiceManager):
mock_which.return_value = "/sbin/fence_sbd"
sbdmanager_instance = SBDManager(device_list_to_init=['/dev/sbd_device'], timeout_dict={'watchdog': 5, 'msgwait': 10})
sbdmanager_instance.initialize_sbd()
mock_logger_info.assert_has_calls([
Expand Down