Skip to content

Commit 34d6d5d

Browse files
committed
el9to10: actors: mysql: Add config compatibility check
1 parent 4162f6b commit 34d6d5d

2 files changed

Lines changed: 121 additions & 50 deletions

File tree

repos/system_upgrade/el9toel10/actors/mysqlcheck/actor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from leapp.actors import Actor
2-
from leapp.libraries.actor.mysqlcheck import report_installed_packages
2+
from leapp.libraries.actor.mysqlcheck import MySQLCheckLib
33
from leapp.models import DistributionSignedRPM, Report
44
from leapp.tags import ChecksPhaseTag, IPUWorkflowTag
55

@@ -17,4 +17,5 @@ class MySQLCheck(Actor):
1717
tags = (ChecksPhaseTag, IPUWorkflowTag)
1818

1919
def process(self):
20-
report_installed_packages()
20+
lib = MySQLCheckLib()
21+
lib.report_installed_packages()

repos/system_upgrade/el9toel10/actors/mysqlcheck/libraries/mysqlcheck.py

Lines changed: 118 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,121 @@
33
from leapp.libraries.stdlib import api
44
from leapp.models import DistributionSignedRPM
55

6-
# Summary for mysql-server report
7-
report_server_inst_summary = (
8-
'MySQL server component will be upgraded. Since RHEL-10 includes'
9-
' MySQL server 8.4 by default, which is incompatible with 8.0'
10-
' included in RHEL-9, it is necessary to proceed with additional steps'
11-
' for the complete upgrade of the MySQL data.'
12-
)
13-
14-
report_server_inst_hint = (
15-
'Back up your data before proceeding with the upgrade'
16-
' and follow steps in the documentation section "Migrating to a RHEL 10 version of MySQL"'
17-
' after the upgrade.'
18-
)
19-
20-
# Link URL for mysql-server report
21-
report_server_inst_link_url = 'https://access.redhat.com/articles/7099234'
22-
23-
24-
def _report_server_installed():
25-
"""
26-
Create report on mysql-server package installation detection.
27-
28-
Should remind user about present MySQL server package
29-
installation, warn them about necessary additional steps, and
30-
redirect them to online documentation for the upgrade process.
31-
"""
32-
reporting.create_report([
33-
reporting.Title('MySQL (mysql-server) has been detected on your system'),
34-
reporting.Summary(report_server_inst_summary),
35-
reporting.Severity(reporting.Severity.MEDIUM),
36-
reporting.Groups([reporting.Groups.SERVICES]),
37-
reporting.ExternalLink(title='Migrating to a RHEL 10 version of MySQL',
38-
url=report_server_inst_link_url),
39-
reporting.RelatedResource('package', 'mysql-server'),
40-
reporting.Remediation(hint=report_server_inst_hint),
41-
])
42-
43-
44-
def report_installed_packages(_context=api):
45-
"""
46-
Create reports according to detected MySQL packages.
47-
48-
Create the report if the mysql-server rpm (RH signed) is installed.
49-
"""
50-
has_server = has_package(DistributionSignedRPM, 'mysql-server', context=_context)
51-
52-
if has_server:
53-
_report_server_installed()
6+
import subprocess
7+
8+
9+
class MySQLCheckLib:
10+
REMOVED_ARGS = [
11+
'--avoid-temporal-upgrade',
12+
'--show-old-temporals',
13+
'--old',
14+
'--new',
15+
'--default-authentication-plugin',
16+
'--no-dd-upgrade',
17+
'--language',
18+
'--ssl',
19+
'--admin-ssl',
20+
'--character-set-client-handshake',
21+
'--old-style-user-limits',
22+
]
23+
24+
# Summary for mysql-server report
25+
report_server_inst_summary = (
26+
'MySQL server component will be upgraded.\n'
27+
'Since RHEL-10 includes MySQL server 8.4 by default, it might be necessary'
28+
' to proceed with additional steps.'
29+
'\n'
30+
)
31+
32+
report_server_inst_hint = (
33+
'Back up your data before proceeding with the upgrade'
34+
' and follow steps in the documentation section "Migrating to a RHEL 10 version of MySQL"'
35+
' after the upgrade.'
36+
)
37+
38+
# Link URL for mysql-server report
39+
report_server_inst_link_url = 'https://access.redhat.com/articles/7099234'
40+
41+
# Default title
42+
report_title = 'MySQL (mysql-server) has been detected on your system'
43+
44+
# Default severity
45+
report_severity = reporting.Severity.MEDIUM
46+
47+
found_arguments = set()
48+
found_options = set()
49+
50+
def _generate_report(self):
51+
"""
52+
Create report on mysql-server package installation detection.
53+
54+
Should remind user about present MySQL server package
55+
installation, warn them about necessary additional steps, and
56+
redirect them to online documentation for the upgrade process.
57+
"""
58+
59+
if self.found_arguments or self.found_options:
60+
self.report_severity = reporting.Severity.HIGH
61+
self.report_title = 'MySQL (mysql-server) seems to be using deprecated config options'
62+
self.report_server_inst_summary += (
63+
'\nWarning:\n'
64+
'It seems that some config options currently used for MySQL server'
65+
' will be removed in updated MySQL server.\n'
66+
'If you proceed with the update now, without addressing this issue,'
67+
' the MySQL server will fail to start until the config is fixed.\n'
68+
'Detected deprecated options:\n'
69+
)
70+
for arg in self.found_options:
71+
self.report_server_inst_summary += f"{arg} in MySQL config file\n"
72+
for arg in self.found_arguments:
73+
self.report_server_inst_summary += f"{arg} in SystemD service override\n"
74+
75+
reporting.create_report([
76+
reporting.Title(self.report_title),
77+
reporting.Summary(self.report_server_inst_summary),
78+
reporting.Severity(self.report_severity),
79+
reporting.Groups([reporting.Groups.SERVICES]),
80+
reporting.ExternalLink(title='Migrating to a RHEL 10 version of MySQL',
81+
url=self.report_server_inst_link_url),
82+
reporting.RelatedResource('package', 'mysql-server'),
83+
reporting.Remediation(hint=self.report_server_inst_hint),
84+
])
85+
86+
def _check_incompatible_config(self):
87+
# mysqld --validate-config --log-error-verbosity=2
88+
# 2024-12-18T11:40:04.725073Z 0 [Warning] [MY-011069] [Server]
89+
# The syntax '--old' is deprecated and will be removed in a future release.
90+
out = subprocess.run(['mysqld', '--validate-config', '--log-error-verbosity=2'],
91+
capture_output=True,
92+
check=False)
93+
94+
stderr = out.stderr.decode("utf-8")
95+
if 'deprecated' in stderr:
96+
self.found_options = {arg for arg
97+
in self.REMOVED_ARGS
98+
if arg in stderr}
99+
100+
def _check_incompatible_launch_param(self):
101+
# Check /etc/systemd/system/mysqld.service.d/override.conf
102+
try:
103+
with open('/etc/systemd/system/mysqld.service.d/override.conf') as f:
104+
file_content = f.read()
105+
self.found_arguments = {arg for arg
106+
in self.REMOVED_ARGS
107+
if arg in file_content}
108+
except OSError:
109+
# File probably doesn't exist, ignore it and pass
110+
pass
111+
112+
def report_installed_packages(self, _context=api):
113+
"""
114+
Create reports according to detected MySQL packages.
115+
116+
Create the report if the mysql-server rpm (RH signed) is installed.
117+
"""
118+
119+
self._check_incompatible_config()
120+
self._check_incompatible_launch_param()
121+
122+
if has_package(DistributionSignedRPM, 'mysql-server', context=_context):
123+
self._generate_report()

0 commit comments

Comments
 (0)