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

mysql_service resource silently fails when not named default #666

Open axl89 opened 3 years ago

axl89 commented 3 years ago

:ghost: Brief Description

When using the mysql_service resource with a different name than default, although the Chef converge phase exits successfully, the MySQL service is not able to start.

:warning: This only happens with Dokken based kitchens, not with Vagrant.

:pancakes: Cookbook version

10.1.1

:woman_cook: Chef-Infra Version

16.11.7

:tophat: Platform details

Dokken Ubuntu 20.04 (see used kitchen YAML file)

Steps To Reproduce

  1. Create a recipe as follows:
apt_update 'all platforms' do
  action :update
  only_if { platform_family?('debian') }
end

yum_mysql_community_repo 'mysql_repo' do
  version node['scalefast_mysql']['service']['version']
  only_if { platform_family?('rhel') || platform_family?('amazon') }
end

# Copy pasted from the README.md
mysql_service 'foo' do
  port '3306'
  version '8.0'
  initial_root_password 'change me'
  action [:create, :start]
end
  1. Converge
  2. Use kitchen login to go inside the system
  3. Confirm that MySQL is dead:
root@dokken:/# systemctl status mysql-foo.service
● mysql-foo.service - mysql_service[mysql-foo]
     Loaded: loaded (/etc/systemd/system/mysql-foo.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2021-03-21 13:20:12 UTC; 22s ago
    Process: 1006 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 1014 ExecStart=/usr/sbin/mysqld --defaults-file=/etc/mysql-foo/my.cnf --basedir=/usr (code=exited, status=1/FAILURE)
    Process: 1015 ExecStartPost=/usr/share/mysql/mysql-systemd-start (code=exited, status=0/SUCCESS)
   Main PID: 1014 (code=exited, status=1/FAILURE)

Mar 21 13:20:12 dokken systemd[1]: mysql-foo.service: Scheduled restart job, restart counter is at 5.
Mar 21 13:20:12 dokken systemd[1]: Stopped mysql_service[mysql-foo].
Mar 21 13:20:12 dokken systemd[1]: mysql-foo.service: Start request repeated too quickly.
Mar 21 13:20:12 dokken systemd[1]: mysql-foo.service: Failed with result 'exit-code'.
Mar 21 13:20:12 dokken systemd[1]: Failed to start mysql_service[mysql-foo].

:police_car: Expected behavior

MySQL service should be running.

:heavy_plus_sign: Additional context

The problem seems to be a permission's issue, since when running MySQL manually with /usr/sbin/mysqld --defaults-file=/etc/mysql-foo/my.cnf --basedir=/usr the output is:

root@dokken:/# /usr/sbin/mysqld --defaults-file=/etc/mysql-foo/my.cnf --basedir=/usr
mysqld: [ERROR] Failed to open required defaults file: /etc/mysql-foo/my.cnf
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

I have confirmed that this behavior does not occur when the mysql_service is just named default.