Skip to content

Commit

Permalink
Dev: bootstrap: add gfs2 stage functionality (Technical Preview) (#1628)
Browse files Browse the repository at this point in the history
## Usage
```
# Setup the cluster on the current node, with SBD+GFS2
crm cluster init -s <share disk1> -g <share disk2> -y

# Setup the cluster on the current node, with SBD+GFS2+Cluster LVM
crm cluster init -s <share disk1> -g <share disk2> -g <share disk3> -C -y

# Add GFS2+Cluster LVM on a running cluster
crm cluster init gfs2 -g <share disk1> -g <share disk2> -C -y
```

BTW, -o option is still available to bootstrapping OCFS2, if applicable

Test packages:
https://build.opensuse.org/projects/home:XinLiang:branches:network:ha-clustering:Factory/packages/crmsh/repositories/openSUSE_Tumbleweed/binaries
  • Loading branch information
liangxin1300 authored Dec 25, 2024
2 parents 562ce84 + 28fe540 commit 66a75d1
Show file tree
Hide file tree
Showing 13 changed files with 1,158 additions and 6 deletions.
42 changes: 40 additions & 2 deletions crmsh/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from . import userdir
from .constants import QDEVICE_HELP_INFO, STONITH_TIMEOUT_DEFAULT,\
REJOIN_COUNT, REJOIN_INTERVAL, PCMK_DELAY_MAX, CSYNC2_SERVICE, WAIT_TIMEOUT_MS_DEFAULT
from . import cluster_fs
from . import qdevice
from . import parallax
from . import log
Expand Down Expand Up @@ -70,7 +71,7 @@
"/etc/samba/smb.conf", SYSCONFIG_NFS, SYSCONFIG_PCMK, SBDManager.SYSCONFIG_SBD, PCMK_REMOTE_AUTH, watchdog.Watchdog.WATCHDOG_CFG,
PROFILES_FILE, CRM_CFG, SBDManager.SBD_SYSTEMD_DELAY_START_DIR)

INIT_STAGES_EXTERNAL = ("ssh", "csync2", "corosync", "sbd", "cluster", "admin", "qdevice")
INIT_STAGES_EXTERNAL = ("ssh", "csync2", "corosync", "sbd", "cluster", "ocfs2", "gfs2", "admin", "qdevice")
INIT_STAGES_INTERNAL = ("csync2_remote", "qnetd_remote")
INIT_STAGES_ALL = INIT_STAGES_EXTERNAL + INIT_STAGES_INTERNAL
JOIN_STAGES_EXTERNAL = ("ssh", "csync2", "ssh_merge", "cluster")
Expand Down Expand Up @@ -111,6 +112,10 @@ def __init__(self):
self.qdevice_heuristics = None
self.qdevice_heuristics_mode = None
self.qdevice_rm_flag = None
self.ocfs2_devices = []
self.gfs2_devices = []
self.use_cluster_lvm2 = None
self.mount_point = None
self.cluster_node = None
self.force = None
self.arbitrator = None
Expand Down Expand Up @@ -269,7 +274,7 @@ def _validate_stage(self):
if self.type == "init":
if self.stage not in INIT_STAGES_ALL:
utils.fatal(f"Invalid stage: {self.stage}(available stages: {', '.join(INIT_STAGES_EXTERNAL)})")
if self.stage in ("admin", "qdevice") and not self.cluster_is_running:
if self.stage in ("admin", "qdevice", "ocfs2") and not self.cluster_is_running:
utils.fatal(f"Cluster is inactive, can't run '{self.stage}' stage")
if self.stage in ("corosync", "cluster") and self.cluster_is_running:
utils.fatal(f"Cluster is active, can't run '{self.stage}' stage")
Expand All @@ -288,6 +293,8 @@ def validate_option(self):
"""
if self.qdevice_inst:
self.qdevice_inst.valid_qdevice_options()
if self.ocfs2_devices or self.gfs2_devices or self.stage in ("ocfs2", "gfs2"):
cluster_fs.ClusterFSManager.pre_verify(self)
if not self.skip_csync2 and self.type == "init":
self.skip_csync2 = utils.get_boolean(os.getenv("SKIP_CSYNC2_SYNC"))
if self.skip_csync2 and self.stage:
Expand Down Expand Up @@ -1402,6 +1409,26 @@ def init_sbd():
_context.sbd_manager.init_and_deploy_sbd()


def init_ocfs2():
"""
OCFS2 configure process
"""
if not _context.ocfs2_devices:
return
ocfs2_manager = cluster_fs.ClusterFSManager(_context)
ocfs2_manager.init()


def init_gfs2():
"""
GFS2 configure process
"""
if not _context.gfs2_devices:
return
gfs2_manager = cluster_fs.ClusterFSManager(_context)
gfs2_manager.init()


def init_cluster():
"""
Initial cluster configuration.
Expand Down Expand Up @@ -2187,6 +2214,8 @@ def bootstrap_init(context):
init_cluster()
init_admin()
init_qdevice()
init_ocfs2()
init_gfs2()
except lock.ClaimLockError as err:
utils.fatal(err)

Expand Down Expand Up @@ -2284,6 +2313,7 @@ def bootstrap_join(context):
join_csync2(cluster_node, remote_user)
join_ssh_merge(cluster_node, remote_user)
probe_partitions()
join_cluster_fs(cluster_node, remote_user)
join_cluster(cluster_node, remote_user)
except (lock.SSHError, lock.ClaimLockError) as err:
utils.fatal(err)
Expand All @@ -2295,6 +2325,14 @@ def bootstrap_finished():
logger.info("Done (log saved to %s on %s)", log.CRMSH_LOG_FILE, utils.this_node())


def join_cluster_fs(peer_host, peer_user):
"""
If init node configured OCFS2/GFS2 device, verify that device on join node
"""
inst = cluster_fs.ClusterFSManager(_context)
inst.join(peer_host)


def remove_qdevice() -> None:
"""
Remove qdevice service and configuration from cluster
Expand Down
Loading

0 comments on commit 66a75d1

Please sign in to comment.