Skip to content

Commit

Permalink
Dev: migration: refine message wording (jsc#PED-11808)
Browse files Browse the repository at this point in the history
(cherry picked from commit 97fa52b)
  • Loading branch information
nicholasyang2022 committed Jan 23, 2025
1 parent 219cb15 commit 16cd739
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
25 changes: 9 additions & 16 deletions crmsh/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,7 @@ def write_in_color(f, color: str, text: str):
f.write(text)

def end(self):
if self.has_problems:
self.write_in_color(sys.stdout, constants.RED, '[FAIL]\n\n')
else:
self.write_in_color(sys.stdout, constants.GREEN, '[PASS]\n\n')
if not self.has_problems:
self.write_in_color(sys.stdout, constants.GREEN, '[PASS]\n')
sys.stdout.write('\n')


def migrate():
Expand All @@ -154,7 +149,7 @@ def check(args: typing.Sequence[str]) -> int:
if not parsed_args.local and not parsed_args.json:
check_remote_yield = check_remote()
next(check_remote_yield)
print('------ localhost ------')
print('------ corosync @ localhost ------')
else:
check_remote_yield = itertools.repeat(0)
match parsed_args.json:
Expand All @@ -173,6 +168,7 @@ def check(args: typing.Sequence[str]) -> int:
next(check_remote_yield)
print('------ corosync @ localhost ------')
check_local(handler)
print('------ cib ------')
check_global(handler)
handler.end()
match handler:
Expand All @@ -189,12 +185,12 @@ def check(args: typing.Sequence[str]) -> int:
print('****** summary ******')
if ret == 0:
CheckResultInteractiveHandler.write_in_color(sys.stdout, constants.GREEN, '[INFO]')
sys.stdout.write(' Please run "crm cluster health sles16 --fix" on on any one of above nodes, after migrating all the nodes to SLES 16.\n')
sys.stdout.write(' Please run "crm cluster health sles16 --fix" on on any one of above nodes.\n')
CheckResultInteractiveHandler.write_in_color(sys.stdout, constants.GREEN, '[PASS]')
sys.stdout.write(' This cluster is good to migrate to SLES 16.\n')
else:
CheckResultInteractiveHandler.write_in_color(sys.stdout, constants.RED, '[FAIL]')
sys.stdout.write(' Please fix all the "FAIL" problems above before migrating to SLES 16.\n')
sys.stdout.write(' The pacemaker cluster stack can not migrate to SLES 16.\n')
return ret


Expand All @@ -218,7 +214,7 @@ def run(self):
prun_thread.join()
ret = 0
for host, result in prun_thread.result.items():
sys.stdout.write(f'------ {host} ------\n')
sys.stdout.write(f'------ corosync @ {host} ------\n')
match result:
case prun.SSHError() as e:
handler.write_in_color(
Expand Down Expand Up @@ -339,8 +335,7 @@ def _check_unsupported_corosync_transport(handler: CheckResultHandler, dom):
except KeyError:
# looks like a corosync 3 config
return
handler.handle_tip(f'Corosync transport "{transport}" will be deprecated in corosync 3.', [
'Run "crm health sles16 --fix" to migrate it to transport "knet".',
handler.handle_tip(f'Corosync transport "{transport}" will be deprecated in corosync 3. Please use knet.', [
])


Expand Down Expand Up @@ -528,8 +523,7 @@ def check_unsupported_resource_agents(handler: CheckResultHandler):
ocf_resource_agents.append(resource_agent)
elif resource_agent.m_class == 'stonith':
if resource_agent.m_type == 'external/sbd':
handler.handle_tip('stonith:external/sbd will be removed.', [
'* Please replace it with stonith:fence_sbd.'
handler.handle_tip('stonith:external/sbd will be removed. Please use stonith:fence_sbd', [
])
else:
stonith_resource_agents.append(resource_agent)
Expand Down Expand Up @@ -605,6 +599,5 @@ def _check_removed_resource_agents(

def _check_ocfs2(handler: CheckResultHandler, cib: lxml.etree.Element):
if cibquery.has_primitive_filesystem_with_fstype(cib, 'ocfs2'):
handler.handle_problem(False, 'OCFS2 is not supported in SLES 16.', [
'* Before migrating to SLES 16, replace it with GFS2.',
handler.handle_problem(False, 'OCFS2 is not supported in SLES 16. Please use GFS2.', [
])
6 changes: 3 additions & 3 deletions test/features/migration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: migration
And Run "crm cluster init -y -N hanode2" OK on "hanode1"
When Try "crm cluster health sles16" on "hanode1"
Then Expected return code is "1"
And Expect stdout contains snippets ["[WARN] Corosync transport \"udpu\" will be deprecated in corosync 3.", "[FAIL] Please fix all the \"FAIL\" problems above before migrating to SLES 16.", "----- localhost -----", "----- hanode2 -----"].
And Expect stdout contains snippets ["[WARN] Corosync transport \"udpu\" will be deprecated in corosync 3.", "[FAIL] The pacemaker cluster stack can not migrate to SLES 16. Please fix all the \"FAIL\" problems above before migrating to SLES 16.", "----- corosync @ localhost -----", "----- corosync @ hanode2 -----"].

Scenario: Should not run fixes.
When Try "crm cluster health sles16 --fix" on "hanode1"
Expand All @@ -21,10 +21,10 @@ Feature: migration
When Run "crm cluster stop --all" on "hanode1"
And Try "crm cluster health sles16" on "hanode1"
Then Expected return code is "1"
And Expect stdout contains snippets ["Check results may be outdated or inaccurate.", "[WARN] Corosync transport \"udpu\" will be deprecated in corosync 3.", "[FAIL] Please fix all the \"FAIL\" problems above before migrating to SLES 16.", "----- localhost -----", "----- hanode2 -----"].
And Expect stdout contains snippets ["Check results may be outdated or inaccurate.", "[WARN] Corosync transport \"udpu\" will be deprecated in corosync 3.", "[FAIL] The pacemaker cluster stack can not migrate to SLES 16. Please fix all the \"FAIL\" problems above before migrating to SLES 16.", "----- corosync @ localhost -----", "----- corosync @ hanode2 -----"].

Scenario: Run pre-migration checks when some of the nodes are offline.
When Run "systemctl stop sshd" on "hanode2"
And Try "crm cluster health sles16" on "hanode1"
Then Expected return code is "1"
And Expect stdout contains snippets ["Cannot create SSH connection to", "[FAIL] Please fix all the \"FAIL\" problems above before migrating to SLES 16.", "----- localhost -----", "----- hanode2 -----"].
And Expect stdout contains snippets ["Cannot create SSH connection to", "[FAIL] The pacemaker cluster stack can not migrate to SLES 16. Please fix all the \"FAIL\" problems above before migrating to SLES 16.", "----- corosync @ localhost -----", "----- corosync @ hanode2 -----"].

0 comments on commit 16cd739

Please sign in to comment.