Skip to content

Commit

Permalink
Dev: pre-migration: check removed resource agents (jsc#PED-11808)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasyang2022 committed Dec 26, 2024
1 parent a2518dd commit 5e56723
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 0 deletions.
88 changes: 88 additions & 0 deletions crmsh/migration-supported-resource-agents.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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
12 changes: 12 additions & 0 deletions crmsh/migration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import json
import logging
import pkgutil
import re
import subprocess
import sys
Expand Down Expand Up @@ -264,6 +265,7 @@ def check_unsupported_resource_agents(handler: CheckResultHandler):
crm_mon = xmlutil.CrmMonXmlParser()
resource_agents = crm_mon.get_configured_resource_agents()
_check_saphana_resource_agent(handler, resource_agents)
_check_removed_resource_agents(handler, resource_agents)


def _check_saphana_resource_agent(handler: CheckResultHandler, resource_agents: typing.Set[str]):
Expand All @@ -283,3 +285,13 @@ def _check_saphana_resource_agent(handler: CheckResultHandler, resource_agents:
handler.handle_problem(False, 'SAPHanaSR Classic will be removed in SLES 16.', [
'Before migrating to SLES 16, replace it with SAPHanaSR-angi.',
])

def _check_removed_resource_agents(handler: CheckResultHandler, resource_agents: typing.Set[str]):
supported_resource_agents = set(pkgutil.get_data(
'crmsh', 'migration-supported-resource-agents.txt'
).decode('ascii').splitlines())
unsupported_resource_agents = [x for x in resource_agents if x not in supported_resource_agents]
if unsupported_resource_agents:
handler.handle_problem(False, 'The following resource agents will be removed in SLES 16.', [
f'* {x}' for x in unsupported_resource_agents
])
1 change: 1 addition & 0 deletions data-manifest
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ test/unittests/test_crashtest_utils.py
test/unittests/test_gv.py
test/unittests/test_handles.py
test/unittests/test_lock.py
test/unittests/test_migration.py
test/unittests/test_objset.py
test/unittests/test_ocfs2.py
test/unittests/test_parallax.py
Expand Down
17 changes: 17 additions & 0 deletions test/unittests/test_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import unittest
from unittest import mock

from crmsh import migration


class TestCheckRemovedResourceAgents(unittest.TestCase):
def setUp(self):
self._handler = mock.Mock(migration.CheckResultHandler)

def test_unsupported_resource_agent(self):
migration._check_removed_resource_agents(self._handler, {'foo::bar'})
self._handler.handle_problem.assert_called_once()

def test_supported_resource_agent(self):
migration._check_removed_resource_agents(self._handler, {'ocf::heartbeat:IPaddr2'})
self._handler.handle_problem.assert_not_called()

0 comments on commit 5e56723

Please sign in to comment.