Skip to content

Commit a33e4b2

Browse files
committed
Dev: sbd: Remove sbd configuration directories while removing cluster node
1 parent f6e3881 commit a33e4b2

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

crmsh/bootstrap.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def __init__(self):
138138
self.default_nic = None
139139
self.default_ip_list = []
140140
self.corosync_conf_orig = None
141-
self.rm_list = [sbd.SBDManager.SYSCONFIG_SBD, CSYNC2_CFG, corosync.conf(), CSYNC2_KEY,
141+
self.rm_list = [CSYNC2_CFG, corosync.conf(), CSYNC2_KEY,
142142
COROSYNC_AUTH, "/var/lib/pacemaker/cib/*",
143143
"/var/lib/corosync/*", "/var/lib/pacemaker/pengine/*", PCMK_REMOTE_AUTH,
144144
"/var/lib/csync2/*", "~/.config/crm/*"]
@@ -2220,10 +2220,8 @@ def rm_configuration_files(remote=None):
22202220
"""
22212221
shell = sh.cluster_shell()
22222222
shell.get_stdout_or_raise_error("rm -f {}".format(' '.join(_context.rm_list)), remote)
2223-
# restore original sbd configuration file from /usr/share/fillup-templates/sysconfig.sbd
2224-
if utils.package_is_installed("sbd", remote_addr=remote):
2225-
cmd = "cp {} {}".format(sbd.SBDManager.SYSCONFIG_SBD_TEMPLATE, sbd.SBDManager.SYSCONFIG_SBD)
2226-
shell.get_stdout_or_raise_error(cmd, remote)
2223+
if os.path.exists(sbd.SBDManager.SYSCONFIG_SBD):
2224+
sbd.cleanup_sbd_configurations(remote)
22272225

22282226

22292227
def remove_node_from_cluster(node, dead_node=False):

crmsh/sbd.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from . import corosync
1010
from . import xmlutil
1111
from . import watchdog
12-
from . import parallax
1312
from .service_manager import ServiceManager
1413
from .sh import ShellUtils
1514

@@ -787,6 +786,19 @@ def cleanup_existing_sbd_resource():
787786
utils.ext_cmd("crm configure delete {}".format(' '.join(sbd_id_list)))
788787

789788

789+
def cleanup_sbd_configurations(remote=None):
790+
shell = sh.cluster_shell()
791+
sysconfig_sbd_bak = f"{SBDManager.SYSCONFIG_SBD}.bak"
792+
logger.info("Rename %s to %s on node %s",
793+
SBDManager.SYSCONFIG_SBD, sysconfig_sbd_bak, remote or utils.this_node())
794+
cmd = f"test -f {SBDManager.SYSCONFIG_SBD} && mv {SBDManager.SYSCONFIG_SBD} {sysconfig_sbd_bak} || exit 0"
795+
shell.get_stdout_or_raise_error(cmd, host=remote)
796+
797+
for _dir in [SBDManager.SBD_SYSTEMD_DELAY_START_DIR, SBDManager.SBD_SYSTEMD_DELAY_START_DISABLE_DIR]:
798+
cmd = f"test -d {_dir} && rm -rf {_dir} && systemctl daemon-reload || exit 0"
799+
shell.get_stdout_or_raise_error(cmd, host=remote)
800+
801+
790802
def purge_sbd_from_cluster():
791803
'''
792804
Purge SBD from cluster, the process includes:
@@ -804,17 +816,10 @@ def purge_sbd_from_cluster():
804816
if service_manager.service_is_enabled(constants.SBD_SERVICE, node):
805817
logger.info("Disable %s on node %s", constants.SBD_SERVICE, node)
806818
service_manager.disable_service(constants.SBD_SERVICE, node)
807-
808-
config_bak = f"{SBDManager.SYSCONFIG_SBD}.bak"
809-
logger.info("Move %s to %s on all nodes", SBDManager.SYSCONFIG_SBD, config_bak)
810-
utils.cluster_run_cmd(f"mv {SBDManager.SYSCONFIG_SBD} {config_bak}")
819+
cleanup_sbd_configurations(node)
811820

812821
out = sh.cluster_shell().get_stdout_or_raise_error("stonith_admin -L")
813822
res = re.search("([0-9]+) fence device[s]* found", out)
814823
# after disable sbd.service, check if sbd is the last stonith device
815824
if res and int(res.group(1)) <= 1:
816825
utils.cleanup_stonith_related_properties()
817-
818-
for _dir in [SBDManager.SBD_SYSTEMD_DELAY_START_DIR, SBDManager.SBD_SYSTEMD_DELAY_START_DISABLE_DIR]:
819-
cmd = f"test -d {_dir} && rm -rf {_dir} || exit 0"
820-
parallax.parallax_call(cluster_nodes, cmd)

0 commit comments

Comments
 (0)