55
66import subprocess
77
8+ FMT_LIST_SEPARATOR = '\n - '
9+
810
911class MySQLCheckLib :
1012 REMOVED_ARGS = [
@@ -21,68 +23,131 @@ class MySQLCheckLib:
2123 '--old-style-user-limits' ,
2224 ]
2325
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-
3826 # Link URL for mysql-server report
3927 report_server_inst_link_url = 'https://access.redhat.com/articles/7099234'
4028
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-
4729 found_arguments = set ()
4830 found_options = set ()
4931
50- def _generate_report (self ):
32+ def _generate_mysql_present_report (self ):
5133 """
5234 Create report on mysql-server package installation detection.
5335
5436 Should remind user about present MySQL server package
5537 installation, warn them about necessary additional steps, and
5638 redirect them to online documentation for the upgrade process.
39+
40+ This report is used in case MySQL package is detected, but no
41+ immediate action is needed.
42+ """
43+ reporting .create_report ([
44+ reporting .Title ('Further action to upgrade MySQL might be needed' ),
45+ reporting .Summary ((
46+ 'MySQL server component will be upgraded. '
47+ 'Since RHEL-10 includes MySQL server 8.4 by default, '
48+ 'it might be necessary to proceed with additional steps after '
49+ 'RHEL upgrade is completed. In simple setups MySQL server should '
50+ 'automatically upgrade all data on first start, but in more '
51+ 'complicated setups further steps might be needed.'
52+ )),
53+ reporting .Severity (self .report_severity ),
54+ reporting .Groups ([reporting .Severity .LOW ]),
55+ reporting .ExternalLink (title = 'Migrating MySQL databases from RHEL 9 to RHEL 10' ,
56+ url = self .report_server_inst_link_url ),
57+ reporting .RelatedResource ('package' , 'mysql-server' ),
58+ reporting .Remediation (hint = (
59+ 'Dump or backup your data before proceeding with the upgrade '
60+ 'and consult attached article '
61+ '\' Migrating MySQL databases from RHEL 9 to RHEL 10\' '
62+ 'with up to date recommended steps before and after the upgrade - '
63+ 'especially different ways of backing up your data or steps you'
64+ 'may need to take manually.'
65+ )),
66+ ])
67+
68+ def _generate_deprecated_config_report (self ):
5769 """
70+ Create report on mysql-server deprecated configuration.
71+
72+ Apart from showing user the article for upgrade process, we inform the
73+ user that there are deprecated configuration options being used and
74+ proceeding with upgrade will result in MySQL server failing to start.
75+ """
76+
77+ generated_list = ''
78+ if self .found_options :
79+ generated_list += (
80+ 'Following configuration options won\' t work on a new version '
81+ 'of MySQL after upgrading and have to be removed from config files:'
82+ )
5883
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- '\n Warning:\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- )
7084 for arg in self .found_options :
71- self .report_server_inst_summary += f"{ arg } in MySQL config file\n "
85+ self .report_server_inst_summary += FMT_LIST_SEPARATOR + arg
86+
87+ generated_list += (
88+ '\n Default configuration file is present in `/etc/my.cnf`\n '
89+ )
90+
91+ if self .found_arguments :
92+ generated_list += (
93+ 'Following startup argument won\' t work on a new version '
94+ 'of MySQL after upgrading and have to be removed from '
95+ 'systemd service files:'
96+ )
97+
7298 for arg in self .found_arguments :
73- self .report_server_inst_summary += f"{ arg } in SystemD service override\n "
99+ self .report_server_inst_summary += FMT_LIST_SEPARATOR + arg
100+
101+ generated_list += (
102+ '\n Default service override file is present in '
103+ '`/etc/systemd/system/mysqld.service.d/override.conf`'
104+ )
74105
75106 reporting .create_report ([
76- reporting .Title (self .report_title ),
77- reporting .Summary (self .report_server_inst_summary ),
107+ reporting .Title ('MySQL is using configuration that will be invalid after upgrade' ),
108+ reporting .Summary ((
109+ 'MySQL server component will be upgraded. '
110+ 'Since RHEL-10 includes MySQL server 8.4 by default, '
111+ 'it is necessary to proceed with additional steps. '
112+ 'Some options that are currently used in MySQL configuration are '
113+ 'deprecated and will result in MySQL server failing to start '
114+ 'after upgrading.'
115+ 'In simple setups MySQL server should automatically upgrade all '
116+ 'data on first start, after RHEL upgrade is completed. In more '
117+ 'complicated setups further steps might be needed.'
118+ )),
78119 reporting .Severity (self .report_severity ),
79- reporting .Groups ([reporting .Groups . SERVICES ]),
80- reporting .ExternalLink (title = 'Migrating to a RHEL 10 version of MySQL ' ,
120+ reporting .Groups ([reporting .Severity . MEDIUM ]),
121+ reporting .ExternalLink (title = 'Migrating MySQL databases from RHEL 9 to RHEL 10 ' ,
81122 url = self .report_server_inst_link_url ),
82123 reporting .RelatedResource ('package' , 'mysql-server' ),
83- reporting .Remediation (hint = self .report_server_inst_hint ),
124+ reporting .Remediation (hint = (
125+ 'To ensure smooth upgrade process it is strongly recommended to '
126+ 'remove deprecated config options \n ' +
127+ generated_list +
128+ 'Dump or backup your data before proceeding with the upgrade '
129+ 'and consult attached article '
130+ '\' Migrating MySQL databases from RHEL 9 to RHEL 10\' '
131+ 'with up to date recommended steps before and after the upgrade - '
132+ 'especially different ways of backing up your data or steps you'
133+ 'may need to take manually.'
134+ )),
84135 ])
85136
137+ def _generate_report (self ):
138+ """
139+ Create report on mysql-server package installation detection.
140+
141+ Should remind user about present MySQL server package
142+ installation, warn them about necessary additional steps, and
143+ redirect them to online documentation for the upgrade process.
144+ """
145+
146+ if self .found_arguments or self .found_options :
147+ self ._generate_deprecated_config_report ()
148+ else :
149+ self ._generate_mysql_present_report ()
150+
86151 def _check_incompatible_config (self ):
87152 # mysqld --validate-config --log-error-verbosity=2
88153 # 2024-12-18T11:40:04.725073Z 0 [Warning] [MY-011069] [Server]
0 commit comments