sous-chefs / mysql

Development repository for the mysql cookbook
https://supermarket.chef.io/cookbooks/mysql
Apache License 2.0
338 stars 690 forks source link

ExecStartPre and ExecStartPost properties of SystemD unit file points to wrong path #683

Open pmisinsk opened 2 years ago

pmisinsk commented 2 years ago

:speaking_head: Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

:ghost: Non-existing path for ExecStartPre and ExecStartPost properties of SystemD unit file

During bootstrapping of Debian 11 node with this cookbook mysql service fails to start due to wrong path for ExecStartPre and ExecStartPost properties of SystemD unit file.

root@srv2800:~# journalctl -xe
[Brief Description](mysql.service: Failed at step EXEC spawning /usr/share/mysql/mysql-systemd-start: No such file or directory) 
Subject: Process /usr/share/mysql/mysql-systemd-start could not be executed
Defined-By: systemd

root@srv2800:~# systemctl cat mysql
# /etc/systemd/system/mysql.service
[Unit]
Description=mysql_service[mysql-default]
After=syslog.target
After=network.target

[Service]
Type=simple
User=mysql
Group=mysql
PermissionsStartOnly=true
ExecStartPre=/usr/share/mysql/mysql-systemd-start pre

ExecStart=/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/usr
ExecStartPost=/usr/share/mysql/mysql-systemd-start
TimeoutSec=300
Restart=on-failure
RuntimeDirectory=mysqld
RuntimeDirectoryMode=755

[Install]
WantedBy=multi-user.target

root@srv2800:~# ls -la /usr/share/mysql/mysql-systemd-start
ls: cannot access '/usr/share/mysql/mysql-systemd-start': No such file or directory

:pancakes: Cookbook version

cookbook version 11.0.5 - latest at time of submitting this issue (26th Sep 2022)

:woman_cook: Chef-Infra Version

root@srv2800:~# chef-client -v
Chef Infra Client: 17.10.3

:tophat: Platform details

Platform detail:

root@srv2800:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

I am using recommended mysql APT repo from official mysql docs https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/#repo-qg-apt-repo-manual-setup

root@srv2800:~# cat /etc/apt/sources.list.d/mysql.list
deb      http://repo.mysql.com/apt/debian/ bullseye mysql-8.0

:police_car: Expected behavior

It seems APT packages for mysql v8 installs SystemD unit files into path /usr/share/mysql-8.0/ and not into path /usr/share/mysql.

root@srv2800:~# ls -ald /usr/share/mysql-8.0/
drwxr-xr-x 28 root root 4096 Sep 26 12:20 /usr/share/mysql-8.0/

root@srv2800:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

The same behaviour I can confirm on Debian 10 (buster) where are unit files under /usr/share/mysql-8.0 and NOT under /usr/share/mysql:

root@srv242:~# ps -p 1
  PID TTY          TIME CMD
    1 ?        03:52:36 systemd

root@srv242:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

root@srv242:~# dpkg -l | egrep -i mysql
ii  mysql-client                          8.0.20-1debian10                                                          amd64        MySQL Client meta package depending on latest version
ii  mysql-common                          8.0.20-1debian10                                                          amd64        Common files shared between packages
ii  mysql-community-client                8.0.20-1debian10                                                          amd64        MySQL Client
ii  mysql-community-client-core           8.0.20-1debian10                                                          amd64        MySQL Client Core Binaries
ii  mysql-community-server                8.0.20-1debian10                                                          amd64        MySQL Server
ii  mysql-community-server-core           8.0.20-1debian10                                                          amd64        MySQL Server Core Binaires
ii  mysql-server                          8.0.20-1debian10                                                          amd64        MySQL Server meta package depending on latest version

root@srv242:~# dpkg -L mysql-community-client | egrep "/usr/share/mysql"
/usr/share/mysql-8.0
/usr/share/mysql-8.0/charsets
/usr/share/mysql-8.0/charsets/Index.xml
/usr/share/mysql-8.0/charsets/README
/usr/share/mysql-8.0/charsets/armscii8.xml
/usr/share/mysql-8.0/charsets/ascii.xml
/usr/share/mysql-8.0/charsets/cp1250.xml
/usr/share/mysql-8.0/charsets/cp1251.xml
..
..
..

Can you have a look at this https://github.com/sous-chefs/mysql/blob/c1b785f5e9aeb860fbef9448cc86a784987621a4/libraries/helpers.rb#L295

:heavy_plus_sign: Additional context

This is my mysql_service resource defined in my custom cookbook

mysql_service 'default' do
  error_log '/var/log/mysql/error.log'
  version '8.0'
  package_name 'mysql-server'
  package_version '8.0.30-1debian11'
  bind_address '0.0.0.0'
  initial_root_password 'SuperS3cr3tPa$$W0rd'
  action [:create, :start]
end
jychan commented 1 week ago

+1 I am experiencing this issue as well attempting to configure MySQL 8.0 on rhel7/rhel8.