diff --git a/hooks/utils.py b/hooks/utils.py index 7ea6c5d..5c6facb 100644 --- a/hooks/utils.py +++ b/hooks/utils.py @@ -505,6 +505,16 @@ def parse_data(relid, unit, key): def configure_stonith(): + if configure_pacemaker_remote_stonith_resource(): + log('Not disabling STONITH as pacemaker remotes are present', + level=INFO) + else: + log('Disabling STONITH', level=INFO) + cmd = "crm configure property stonith-enabled=false" + pcmk.commit(cmd) + + +def configure_legacy_stonith(): if config('stonith_enabled') not in ['true', 'True', True]: if configure_pacemaker_remote_stonith_resource(): log('Not disabling STONITH as pacemaker remotes are present', @@ -1182,6 +1192,10 @@ def assess_status_helper(): @returns status, message - status is workload status and message is any corresponding messages """ + if config('stonith_enabled') in ['true', 'True', True]: + return( + 'blocked', + 'stonith_enabled config option is no longer supported') if is_unit_upgrading_set(): return ("blocked", diff --git a/unit_tests/test_hacluster_utils.py b/unit_tests/test_hacluster_utils.py index e201b2f..0999891 100644 --- a/unit_tests/test_hacluster_utils.py +++ b/unit_tests/test_hacluster_utils.py @@ -445,21 +445,6 @@ class UtilsTestCase(unittest.TestCase): mock_commit.assert_called_once_with( 'crm configure property stonith-enabled=false') - @mock.patch('pcmk.commit') - @mock.patch.object(utils, 'config') - @mock.patch.object(utils, 'configure_pacemaker_remote_stonith_resource') - def test_configure_stonith_stonith_enabled_false_pcmkr_remote( - self, - mock_cfg_pcmkr_rstonith_res, - mock_config, - mock_commit): - cfg = { - 'stonith_enabled': 'false'} - mock_config.side_effect = lambda key: cfg.get(key) - mock_cfg_pcmkr_rstonith_res.return_value = ['st-res'] - utils.configure_stonith() - self.assertFalse(mock_commit.called) - @mock.patch.object(utils, 'relation_get') def test_parse_data_json(self, relation_get): _rel_data = {