Merge ~lvoytek/ubuntu/+source/mysql-8.0:mysql-fix-my-cnf-symlink-apport into ubuntu/+source/mysql-8.0:ubuntu/devel

Proposed by Lena Voytek
Status: Merged
Merged at revision: e417d5e8ba04504a15491283ba64d82496f60542
Proposed branch: ~lvoytek/ubuntu/+source/mysql-8.0:mysql-fix-my-cnf-symlink-apport
Merge into: ubuntu/+source/mysql-8.0:ubuntu/devel
Diff against target: 34 lines (+14/-1)
2 files modified
debian/additions/source_mysql-8.0.py (+7/-1)
debian/changelog (+7/-0)
Reviewer Review Type Date Requested Status
Robie Basak Approve
Canonical Server Pending
Canonical Server Core Reviewers Pending
Review via email: mp+422034@code.launchpad.net

Description of the change

When apport bugs are submitted for mysql with the default config, it will display my.cnf with

Error: [Errno 40] Too many levels of symbolic links: '/etc/mysql/my.cnf'

which can be an issue when trying to diagnose the actual problem.
This update shows what my.cnf links to if it is linked otherwise it will show the file customized by the user.

To test:

# lxc launch images:ubuntu/kinetic test-kinetic
# lxc exec test-kinetic bash

# apt update && apt dist-upgrade -y

# apt install apport mysql-server software-properties-common

# ubuntu-bug mysql-server
V
- Under the my.cnf section the too many symbolic links error will be shown
C

# add-apt-repository ppa:lvoytek/mysql-8.0-fix-apport-my-cnf-kinetic

- If 8.0.29-0ubuntu1 hasn't been released then enable proposed before updating

# apt update && apt upgrade -y

# export APPORT_DISABLE_DISTRO_CHECK=1

- Check default config
# ubuntu-bug mysql-server
V
- The my.cnf section will now show "MySQLConf.etc.mysql.my.cnf: my.cnf links to /etc/mysql/mysql.cnf"
C

- Check custom config
# rm /etc/mysql/my.cnf
# cp /etc/mysql/mysql.cnf /etc/mysql/my.cnf

# ubuntu-bug mysql-server
V
- The my.cnf section will now show the contents of the file
C

To post a comment you must log in.
Revision history for this message
Robie Basak (racb) wrote :

Looks good, with an inline suggestion.

FTR, I looked up why there was a problem in the first place. Looks like apport.hookutils.read_file() uses os.open(..., os_O_NOFOLLOW) so it's intentional that it doesn't follow symlinks. I found that surprising, but I guess it does make sense to report the symlink target in this case instead, so doing it in the mysql-server apport hook works.

review: Approve
Revision history for this message
Lena Voytek (lvoytek) wrote :

> Looks good, with an inline suggestion.

That's a much better way of going about it, thanks! I updated the code and tested the apport file in an LXD container. The ppa version for it is currently building.

Revision history for this message
Lena Voytek (lvoytek) wrote :

The ppa finally finished building. I ran the autopkgtests against it locally in a vm and all tests passed

Revision history for this message
Robie Basak (racb) wrote :

Uploaded. Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/additions/source_mysql-8.0.py b/debian/additions/source_mysql-8.0.py
2index ea3fb84..63754e3 100644
3--- a/debian/additions/source_mysql-8.0.py
4+++ b/debian/additions/source_mysql-8.0.py
5@@ -78,7 +78,13 @@ def add_info(report, ui=None):
6 report['UnreportableReason'] = "Missing /etc/mysql directory"
7 return False
8 else:
9- _add_my_conf_files(report, '/etc/mysql/my.cnf')
10+ # By default my.cnf is a symlink, and _add_my_conf_files calls apport.hookutils.read_file()
11+ # doesn't support them, so send the link target separately instead. LP: #1969369
12+ if os.path.islink('/etc/mysql/my.cnf'):
13+ my_cnf_link = os.path.realpath('/etc/mysql/my.cnf')
14+ report['MySQLConf.etc.mysql.my.cnf'] = f'my.cnf links to {my_cnf_link}'
15+ else:
16+ _add_my_conf_files(report, '/etc/mysql/my.cnf')
17 _add_my_conf_files(report, '/etc/mysql/mysql.cnf')
18 for d in ['/etc/mysql/conf.d', '/etc/mysql/mysql.conf.d']:
19 if os.path.isdir(d):
20diff --git a/debian/changelog b/debian/changelog
21index fd67d95..9258571 100644
22--- a/debian/changelog
23+++ b/debian/changelog
24@@ -1,3 +1,10 @@
25+mysql-8.0 (8.0.29-0ubuntu3) kinetic; urgency=medium
26+
27+ * d/a/source_mysql-8.0.py: Fix apport too many symbolic
28+ links report for my.cnf (LP: #1969369)
29+
30+ -- Lena Voytek <lena.voytek@canonical.com> Thu, 12 May 2022 09:00:19 -0700
31+
32 mysql-8.0 (8.0.29-0ubuntu2) kinetic; urgency=medium
33
34 * Add libexpect-perl module to fix mysqlpump_bugs test (LP: #1972737)

Subscribers

People subscribed via source and target branches