saltstack-formulas / mysql-formula

Install the MySQL client and/or server
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
85 stars 369 forks source link

[BUG] Unable to connect to MySQL using CentOS 8 #253

Closed lmeerwood closed 3 years ago

lmeerwood commented 3 years ago

Your setup

CentOS 8 VM with Salt Stack installed.

Formula commit hash / release tag

I'm using the master branch.

Versions reports (master & minion)

Salt Version:
           Salt: 3001

Dependency Versions:
           cffi: 1.11.5
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 2.11.2
        libgit2: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: Not Installed
   pycryptodome: 3.9.8
         pygit2: Not Installed
         Python: 3.6.8 (default, Apr 16 2020, 01:36:27)
   python-gnupg: Not Installed
         PyYAML: 5.3.1
          PyZMQ: 19.0.2
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.2

System Versions:
           dist: centos 8 Core
         locale: UTF-8
        machine: x86_64
        release: 4.18.0-193.19.1.el8_2.x86_64
         system: Linux
        version: CentOS Linux 8 Core

Pillar / config used

I'm using the following Salt Formulas:

mysql.client
mysql.server
mysql.config
mysql.user
mysql.database
mysql.remove_test_database

Bug details

Describe the bug

Whenever I try run a command that uses a Salt MySQL command I get the following error:

MySQL Error 2003: Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)

This doesn't happen for States that run through the cmd function. (E.g. the mysql_root_password state uses cmd.run)

Expected behaviour

Expected it to connect and not fail.

Attempts to fix the bug

I noticed that by adding the socket into the Salt formulas this fixed the issue.

Adding the socket in a variable: https://github.com/lmeerwood/mysql-formula/blob/master/mysql/database.sls#L10

Passing the socket to the state: https://github.com/lmeerwood/mysql-formula/blob/master/mysql/database.sls#L43-L45

I have gone through and done this for all the salt states that have a MySQL state call. If this is an acceptable path forward I am happy to submit a pull request with the changes.

Additional context

I am unsure why this is happening. Looking at /etc/my.cnf.d/server shows that the socket is set correctly in there.

lmeerwood commented 3 years ago

It looks like I've accidentally included my fixes in pull request #252. If they get merged in this will be closable.

noelmcloughlin commented 3 years ago

Fixed in: https://github.com/saltstack-formulas/mysql-formula/pull/252 # centos8 py3