Skip to content

Dev: migration: implement corosync.conf migration for corosync 3 (jsc#PED-8252) #1422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d734737
Dev: migration: implement corosync.conf migration for corosync 3 (jsc…
nicholasyang2022 Oct 23, 2024
50296a4
Dev: migration: populate node name in corosync node list for knet mul…
nicholasyang2022 May 17, 2024
b577b8a
Fix: corosync: use os.env instead of os.getenv for consistency (bsc#1…
nicholasyang2022 May 22, 2024
73e08a7
Dev: migration: implement multicast to knet migration (jsc#PED-8252)
nicholasyang2022 May 22, 2024
42976bc
Dev: profiles: set default crypto_hash to sha256 to follow corosync d…
nicholasyang2022 May 23, 2024
bb1d3bb
Dev: ui_cluster: add 'crm cluster health sles [--fix]' (jsc#PED-8252)
nicholasyang2022 Oct 23, 2024
c98b0ca
Dev: prun: create event loop manually
nicholasyang2022 Oct 31, 2024
dc7deaf
Dev: migration: run checks on remote nodes (jsc#PED-8252)
nicholasyang2022 Nov 1, 2024
212ffb8
Dev: migration: copy migrated corosync.conf to remote nodes (jsc#PED-…
nicholasyang2022 Oct 31, 2024
2425aec
Dev: pre-migration: add checks for used corosync features (jsc#PED-11…
nicholasyang2022 Dec 13, 2024
058c020
Dev: pre-migration: check SAPHanaSR Classic resource agents (jsc#PED-…
nicholasyang2022 Jan 2, 2025
285a16e
Dev: pre-migration: check removed resource agents (jsc#PED-11808)
nicholasyang2022 Dec 31, 2024
2426613
Dev: pre-migration: check removed fence agents (jsc#PED-11808)
nicholasyang2022 Dec 31, 2024
31c6c84
Dev: pre-migration: check if ocfs2 is used (jsc#PED-11808)
nicholasyang2022 Jan 1, 2025
e7cb83a
Dev: add pre-migration checks for pacemaker version (jsc#PED-11808)
nicholasyang2022 Jan 2, 2025
b995f40
Dev: pre-migration: do not colorize hostname header (jsc#PED-11808)
nicholasyang2022 Jan 6, 2025
4a80940
Dev: pre-migration: add completer for 'crm cluster health sles16' (js…
nicholasyang2022 Jan 6, 2025
43f05d1
Fix: ui_cluster: fix do_health usage output
nicholasyang2022 Jan 6, 2025
9dd577c
Dev: pre-migration: add message about removing stonith:external/sbd (…
nicholasyang2022 Jan 7, 2025
afc701f
Doc: ui_cluster: add document for `crm cluster health hawk2|sles16`
nicholasyang2022 Jan 7, 2025
5489382
Fix: cibquery: grouped primitives is missing from query results (jsc#…
nicholasyang2022 Jan 9, 2025
c77a179
Refactor: cibquery: has_primitive_filesystem_ocfs2 to has_primitive_f…
nicholasyang2022 Jan 13, 2025
10f2155
Dev: pre-migration: add summary section to output (jsc#PED-11808)
nicholasyang2022 Jan 13, 2025
f95b050
Dev: migration: refine message wording (jsc#PED-11808)
nicholasyang2022 Feb 6, 2025
dd53f1d
Dev: migration: do not check pacemaker version (jsc#PED-8252)
nicholasyang2022 Feb 7, 2025
0108812
Dev: behave: add functional tests for pre-migration checks (jsc#PED-8…
nicholasyang2022 Feb 13, 2025
375ced4
Fix: migration: should not show pre-migration check summary when call…
nicholasyang2022 Feb 13, 2025
d0ab681
Dev: migration: check if the cluster is already migrated to SLES 16 (…
nicholasyang2022 Feb 19, 2025
06549a9
Dev: migration: split problem level and is_blocker (jsc#PED-8252)
nicholasyang2022 Feb 26, 2025
86c65b3
Dev: migration: add a checker for cib schema version (jsc#PED-8252)
nicholasyang2022 Feb 27, 2025
cbf0c48
Dev: migration: no need to check if cluster services is stopped (jsc#…
nicholasyang2022 Mar 4, 2025
6b50f7b
Fix: migration: should not report need migration when the cluster has…
nicholasyang2022 Mar 5, 2025
7a112fa
Dev: migration: add a message about corosync.conf.bak (jsc#PED-82582)
nicholasyang2022 Mar 5, 2025
249058d
Dev: migration: refine the message about unsupported component versio…
nicholasyang2022 Mar 5, 2025
e7859cc
Fix: migration: IndexError when there is only one interface (jsc#PED-…
nicholasyang2022 Mar 6, 2025
5e15450
Dev: migration: fix incorrect bindnetaddr when migrating a multicast …
nicholasyang2022 Mar 6, 2025
edc97d1
Refactor: cibquery: extract a function to get cluster nodes without s…
nicholasyang2022 Mar 7, 2025
e73323d
Refactor: migration: extract a function _migrate_totem_interface (jsc…
nicholasyang2022 Mar 7, 2025
2c7b93f
Dev: migration: minor refines in message wording
nicholasyang2022 Mar 10, 2025
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
15 changes: 15 additions & 0 deletions .github/workflows/crmsh-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,21 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
flags: integration

functional_test_migration:
runs-on: ubuntu-24.04
timeout-minutes: 40
steps:
- uses: actions/checkout@v4
- name: functional test for migration
run: |
echo '{ "exec-opts": ["native.cgroupdriver=systemd"] }' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker.service
$CONTAINER_SCRIPT `$GET_INDEX_OF migration` && $CONTAINER_SCRIPT -d && $CONTAINER_SCRIPT -u `$GET_INDEX_OF migration`
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: integration

original_regression_test:
runs-on: ubuntu-24.04
timeout-minutes: 40
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include crmsh *.txt
4 changes: 2 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ coverage:
threshold: 0.35%
codecov:
notify:
after_n_builds: 28
after_n_builds: 29
comment:
after_n_builds: 28
after_n_builds: 29
layout: "condensed_header, flags, files, condensed_footer"
51 changes: 51 additions & 0 deletions crmsh/cibquery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""utilities for parsing CIB xml"""
import dataclasses
import typing

import lxml.etree

from crmsh import constants


@dataclasses.dataclass(frozen=True)
class ResourceAgent:
m_class: str
m_provider: typing.Optional[str]
m_type: str


@dataclasses.dataclass(frozen=True)
class ClusterNode:
node_id: int
uname: str


def get_configured_resource_agents(cib: lxml.etree.Element) -> typing.Set[ResourceAgent]:
return set(
ResourceAgent(e.get('class'), e.get('provider'), e.get('type'))
for e in cib.xpath('/cib/configuration/resources//primitive')
)


def has_primitive_filesystem_with_fstype(cib: lxml.etree.Element, fstype: str) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For commonly use purpose, I do think this function can be renamed more commonly, like has_primitive_ra_with, with parameters like type and nvpair's name and value

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do know xml queries can be more flexible, just like JAXB in java. But a complete, user-friendly and reliable implementation needs too much work and is impossible to be included in crmsh. I incline to implement some routines only when we really need to call it from many places. Do you have some real use cases?

return bool(cib.xpath(
'/cib/configuration/resources//primitive[@class="ocf" and @provider="heartbeat" and @type="Filesystem"]'
f'/instance_attributes/nvpair[@name="fstype" and @value="{fstype}"]'
))

def get_cluster_nodes(cib: lxml.etree.Element) -> list[ClusterNode]:
"""Return a list of cluster nodes, excluding pacemaker-remote nodes"""
result = list()
for element in cib.xpath(constants.XML_NODE_PATH):
node_id = element.get('id')
uname = element.get('uname')
if element.get('type') == 'remote':
xpath = "//primitive[@provider='pacemaker' and @type='remote']/instance_attributes/nvpair[@name='server' and @value='{}']".format(

Check warning on line 43 in crmsh/cibquery.py

View check run for this annotation

Codecov / codecov/patch

crmsh/cibquery.py#L43

Added line #L43 was not covered by tests
uname if uname is not None else node_id
)
if cib.xpath(xpath):
continue

Check warning on line 47 in crmsh/cibquery.py

View check run for this annotation

Codecov / codecov/patch

crmsh/cibquery.py#L46-L47

Added lines #L46 - L47 were not covered by tests
assert node_id
assert uname
result.append(ClusterNode(int(node_id), uname))
return result
2 changes: 1 addition & 1 deletion crmsh/corosync.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def configure_two_node(removing: bool = False, qdevice_adding: bool = False) ->


def conf():
return os.getenv('COROSYNC_MAIN_CONFIG_FILE', '/etc/corosync/corosync.conf')
return os.environ.get('COROSYNC_MAIN_CONFIG_FILE', '/etc/corosync/corosync.conf')


def check_tools():
Expand Down
147 changes: 147 additions & 0 deletions crmsh/migration-supported-resource-agents.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
ocf:heartbeat:CTDB
ocf:heartbeat:ClusterMon
ocf:heartbeat:Delay
ocf:heartbeat:Dummy
ocf:heartbeat:Filesystem
ocf:heartbeat:IPaddr2
ocf:heartbeat:IPsrcaddr
ocf:heartbeat:IPv6addr
ocf:heartbeat:LVM-activate
ocf:heartbeat:MailTo
ocf:heartbeat:NodeUtilization
ocf:heartbeat:Raid1
ocf:heartbeat:Route
ocf:heartbeat:SAPDatabase
ocf:heartbeat:SAPInstance
ocf:heartbeat:SendArp
ocf:heartbeat:Squid
ocf:heartbeat:Stateful
ocf:heartbeat:VirtualDomain
ocf:heartbeat:WAS
ocf:heartbeat:WAS6
ocf:heartbeat:Xinetd
ocf:heartbeat:aliyun-vpc-move-ip
ocf:heartbeat:apache
ocf:heartbeat:aws-vpc-move-ip
ocf:heartbeat:aws-vpc-route53
ocf:heartbeat:awseip
ocf:heartbeat:awsvip
ocf:heartbeat:azure-events
ocf:heartbeat:azure-events-az
ocf:heartbeat:azure-lb
ocf:heartbeat:conntrackd
ocf:heartbeat:corosync-qnetd
ocf:heartbeat:crypt
ocf:heartbeat:db2
ocf:heartbeat:dhcpd
ocf:heartbeat:docker
ocf:heartbeat:docker-compose
ocf:heartbeat:dummypy
ocf:heartbeat:ethmonitor
ocf:heartbeat:exportfs
ocf:heartbeat:galera
ocf:heartbeat:garbd
ocf:heartbeat:gcp-ilb
ocf:heartbeat:gcp-pd-move
ocf:heartbeat:gcp-vpc-move-ip
ocf:heartbeat:gcp-vpc-move-vip
ocf:heartbeat:iSCSILogicalUnit
ocf:heartbeat:iSCSITarget
ocf:heartbeat:iface-bridge
ocf:heartbeat:iface-macvlan
ocf:heartbeat:iface-vlan
ocf:heartbeat:ldirectord
ocf:heartbeat:lvmlockd
ocf:heartbeat:mariadb
ocf:heartbeat:mdraid
ocf:heartbeat:mpathpersist
ocf:heartbeat:mysql
ocf:heartbeat:mysql-proxy
ocf:heartbeat:named
ocf:heartbeat:nfsnotify
ocf:heartbeat:nfsserver
ocf:heartbeat:nginx
ocf:heartbeat:nvmet-namespace
ocf:heartbeat:nvmet-port
ocf:heartbeat:nvmet-subsystem
ocf:heartbeat:oraasm
ocf:heartbeat:oracle
ocf:heartbeat:oralsnr
ocf:heartbeat:osceip
ocf:heartbeat:ovsmonitor
ocf:heartbeat:pgagent
ocf:heartbeat:pgsql
ocf:heartbeat:podman
ocf:heartbeat:portblock
ocf:heartbeat:postfix
ocf:heartbeat:powervs-subnet
ocf:heartbeat:rabbitmq-cluster
ocf:heartbeat:rabbitmq-server-ha
ocf:heartbeat:redis
ocf:heartbeat:rsyncd
ocf:heartbeat:sfex
ocf:heartbeat:sg_persist
ocf:heartbeat:slapd
ocf:heartbeat:storage-mon
ocf:heartbeat:symlink
ocf:heartbeat:tomcat
ocf:suse:aws-vpc-move-ip
ocf:suse:SAPHanaController
ocf:suse:SAPHanaFilesystem
ocf:suse:SAPHanaTopology
stonith:fence_aliyun
stonith:fence_alom
stonith:fence_apc
stonith:fence_apc-snmp
stonith:fence_aws
stonith:fence_azure-arm
stonith:fence_bladecenter
stonith:fence_brocade
stonith:fence_cisco-mds
stonith:fence_cisco-ucs
stonith:fence_compute
stonith:fence_docker
stonith:fence_drac5
stonith:fence_eaton-snmp
stonith:fence_eaton-ssh
stonith:fence_emerson
stonith:fence_eps
stonith:fence_gce
stonith:fence_hds-cb
stonith:fence_hpblade
stonith:fence_ibm-powervs
stonith:fence_ibm-vpc
stonith:fence_ibmblade
stonith:fence_ibmz
stonith:fence_ifmib
stonith:fence_ilo-moonshot
stonith:fence_ilo-mp
stonith:fence_ilo-ssh
stonith:fence_ilo2
stonith:fence_intelmodular
stonith:fence_ipdu
stonith:fence_ipmilan
stonith:fence_ironic
stonith:fence_kdump
stonith:fence_ldom
stonith:fence_lpar
stonith:fence_mpath
stonith:fence_netio
stonith:fence_openstack
stonith:fence_pve
stonith:fence_raritan
stonith:fence_rcd-serial
stonith:fence_redfish
stonith:fence_rhevm
stonith:fence_rsa
stonith:fence_rsb
stonith:fence_sanbox2
stonith:fence_sbd
stonith:fence_scsi
stonith:fence_vbox
stonith:fence_virsh
stonith:fence_vmware
stonith:fence_vmware-rest
stonith:fence_wti
stonith:fence_xenapi
stonith:fence_zvm
Loading