forked from ClusterLabs/crmsh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev: ui_corosync: use corosync-cfgtool instead of corosync-cmaptool t…
…o retreive link status (jsc#PED-8083) as the data provided in `corosync-cmaptool -m stats` in not accurate in certain cases.
- Loading branch information
1 parent
12bb26e
commit 293b837
Showing
3 changed files
with
171 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Copyright (C) 2013 Kristoffer Gronlund <[email protected]> | ||
# See COPYING for license information. | ||
import dataclasses | ||
import io | ||
import ipaddress | ||
import json | ||
import re | ||
|
@@ -234,24 +235,28 @@ def _check_link_removable(lm: corosync.LinkManager, linknumber): | |
if not ServiceManager().service_is_active("corosync.service"): | ||
return | ||
nodes = utils.list_cluster_nodes() | ||
for host, result in prun.prun({node: 'corosync-cmapctl -m stats' for node in nodes}).items(): | ||
for host, result in prun.prun({node: 'corosync-cfgtool -s' for node in nodes}).items(): | ||
# for each node <host> in the cluster | ||
match result: | ||
case prun.SSHError() as e: | ||
raise ValueError(str(e)) | ||
case prun.ProcessResult() as x: | ||
if x.returncode != 0: | ||
raise ValueError(f'{host}: {x.returncode}, {sh.Utils.decode_str(x.stderr)}') | ||
stdout = sh.Utils.decode_str(x.stdout) | ||
connected_nodes = { | ||
nodeid | ||
for nodeid, ln, connected in re.findall( | ||
'^stats\\.knet\\.node([0-9]+)\\.link([0-9]+)\\.connected\\W+.*=\\s*([0-9]+)$', | ||
stdout, re.ASCII | re.MULTILINE, | ||
) if connected == '1' # only connected node | ||
and ln != str(linknumber) # filter out the link to be removed | ||
} | ||
# the number of nodes connected to <host> should be equal to the total number of nodes in the cluster | ||
connected_nodes = set() | ||
ln = -1 | ||
for line in io.StringIO(sh.Utils.decode_str(x.stdout)): | ||
mo = re.match('^(?:LINK ID (\\d+)|\\s*nodeid:\\s*(\\d+):\\s*(?:localhost|connected)$)', line) | ||
if mo is None: | ||
continue | ||
if mo.group(1): | ||
ln = int(mo.group(1)) | ||
continue | ||
if ln == linknumber: | ||
# filter out the link to be removed | ||
continue | ||
if mo.group(2): | ||
connected_nodes.add(mo.group(2)) | ||
if len(connected_nodes) < len(next(link for link in lm.links() if link is not None).nodes): | ||
# or <host> will lose quorum | ||
raise ValueError(f'Cannot remove link {linknumber}. Removing this link makes the cluster to lose quorum.') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,8 @@ Feature: crm corosync ui test cases | |
When Run "crm corosync link update 0 [email protected] [email protected] options knet_link_priority=10" on "hanode1" | ||
Then Expected "Restarting corosync.service is needed to apply the changes, ie. crm cluster restart --all" in stderr | ||
Given Run "systemctl restart corosync.service" OK on "hanode1,hanode2" | ||
When Try "crm corosync link add [email protected] [email protected] options knet_link_priority=" on "hanode1" | ||
When Wait "5" seconds | ||
And Try "crm corosync link add [email protected] [email protected] options knet_link_priority=" on "hanode1" | ||
Then Expected "invalid option" in stderr | ||
Given Run "crm corosync link add [email protected] [email protected] options knet_link_priority=11" OK on "hanode1" | ||
When Try "crm corosync link update 1 [email protected]" on "hanode1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters