Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipe not Converging under Centos7 and :create action on Server #285

Open
davidpickwell opened this issue Dec 10, 2019 · 2 comments
Open
Labels
Waiting on Contributor Awaiting on the person who raised this to update

Comments

@davidpickwell
Copy link

👻 Brief Description

A recipe is not converging under Kitchen when the underlying OS is CentOS7 (works fine in CentOS6.9).

The recipe performs a simple install:

mariadb_server_install 'MariaDB Server install' do
  version '10.4.10'
  action [ :install, :create ]
end

The cookbook installs the correct version of MariaDB using the default :install action:

[root@database-01 ~]# mariadb --version
mariadb  Ver 15.1 Distrib 10.4.10-MariaDB, for Linux (x86_64) using readline 5.1

But when the :create action is called, it fails on the Error executing action 'enable' on resource 'service[mysql]'

The reason for this is that the MariaDB service under CentOS7 is called mariadb (not mysql as in CentOS6)

[root@database-01 ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@database-01 ~]# systemctl status mysql
Unit mysql.service could not be found.
[root@database-01 ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.4.10 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: inactive (dead)
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/

It will also enable and start correctly when called manually:

[root@database-01 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/mysql.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/mysqld.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@database-01 ~]# systemctl start mariadb
[root@database-01 ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.4.10 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Tue 2019-12-10 09:39:41 UTC; 4s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 15052 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 15007 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 15005 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 15020 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─15020 /usr/sbin/mysqld

Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10  9:39:41 0 [Note] InnoDB: 10.4.10 started; log sequence numbe...id 21
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10  9:39:41 0 [Note] InnoDB: Loading buffer pool(s) from /var/li..._pool
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10  9:39:41 0 [Note] InnoDB: Buffer pool(s) load completed at 19...39:41
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10  9:39:41 0 [Note] Plugin 'FEEDBACK' is disabled.
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10  9:39:41 0 [Note] Server socket created on IP: '::'.
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10  9:39:41 0 [Note] Reading of all Master_info entries succeeded
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10  9:39:41 0 [Note] Added new Master_info '' to hash table
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: 2019-12-10  9:39:41 0 [Note] /usr/sbin/mysqld: ready for connections.
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network mysqld[15020]: Version: '10.4.10-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3...erver
Dec 10 09:39:41 database-01.testkitchen.eagleeye.network systemd[1]: Started MariaDB 10.4.10 database server.

🥞 Cookbook version

Cookbook Version: 3.1.0

👩‍🍳 Chef-Infra Version

Chef Client version 14.14.29-1

🎩 Platform details

OS Version: CentOS Linux release 7.6.1810 (Core)

Steps To Reproduce

Steps to reproduce the behaviour:

Create a database recipe as above, and kitchen converge a test machine under CentOS7. Kitchen file:

09:20 $ cat .kitchen.local.yml 
---
driver:
  name: vagrant
  customize:
    memory: 4096
    cpus: 2

provisioner:
  product_name: chef
  product_version: 14.14.29
  install_strategy: always
  encrypted_data_bag_secret_key_path: "~/.chef/encrypted_data_bag_secret"
  data_bags_path: "data_bags"
  environments_path: "environments"
  cookbooks_path: "cookbooks"
  roles_path: "roles"
  nodes_path: "test/nodes"
  solo_rb:
    environment: "am-qa"
  attributes:
    deploy_flag: true
    testkitchen: true
    customer: "test"
    resolver:
      nameservers: [
        "1.1.1.1",
        "8.8.8.8",
        "8.8.4.4"
      ]

transport:
  name: sftp
  elevated: true

verifier:
  name: inspec
  sudo: true

platforms:
  - name: centos-7

suites:
  - name: database
    run_list:
      - role[database]
    driver:
      vm_hostname: database-01.testkitchen.eagleeye.network
      network:
      - ["forwarded_port", {guest: 3306, host: 3306}]

🚓 Expected behavior

The converge to successfully complete and start the mariadb service.

➕ Additional context

Believe the issue lies in the helper.rb file (186-188) where it is hardcoded to return the platform_service_name as mysql:

    def platform_service_name(_version = node.run_state['mariadb']['version'])
      'mysql'
    end

This should by mariadb for CentOS7 (not sure for other platforms), such as:

  def platform_service_name
    case node['platform_family']
    when 'rhel'
      'mariadb'
    else
      'mysql'
    end
  end

This is the specific error:

             Mixlib::ShellOut::ShellCommandFailed
             ------------------------------------
             Expected process to exit with [0], but received '1'
             ---- Begin output of /bin/systemctl --system enable mysql ----
             STDOUT: 
             STDERR: Failed to execute operation: No such file or directory
             ---- End output of /bin/systemctl --system enable mysql ----
             Ran /bin/systemctl --system enable mysql returned 1

This is the error trace from the converge:

ErrorTrace.txt

@JohnRoesler
Copy link
Contributor

Would you like to open a pull request to resolve?

@ramereth
Copy link
Contributor

ramereth commented Oct 3, 2020

@davidpickwell is this still happening with the current release of the cookbook?

@ramereth ramereth added the Waiting on Contributor Awaiting on the person who raised this to update label Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting on Contributor Awaiting on the person who raised this to update
Projects
None yet
Development

No branches or pull requests

3 participants