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] Centos 8 - python client for mysql missing #248

Closed campbellmc closed 3 years ago

campbellmc commented 4 years ago

Centos 7 (Mysql-python) not available for Centos 8

Formula commit hash / release tag

mysql-formula commit sha: ba91d9841bd0e096466d78f31efb9cdad00f2263

Versions reports (master & minion)

Salt Version:
           Salt: 3000.3

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: 0.35.2
           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.7
         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.0
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.2

System Versions:
           dist: centos 8.1.1911 Core
         locale: UTF-8
        machine: x86_64
        release: 4.18.0-147.3.1.el8_1.x86_64
         system: Linux
        version: CentOS Linux 8.1.1911 Core

Pillar / config used

None

Bug details

Describe the bug

          ID: mysql_python
    Function: pkg.installed
        Name: MySQL-python
      Result: False
     Comment: Error occurred installing package(s). Additional info follows:

              errors:
                  - Running scope as unit: run-r0c9cfbc85e0f42b9ac871d461a69014a.scope
                    Last metadata expiration check: 0:00:02 ago on Mon Jun 22 03:07:26 2020.
                    No match for argument: MySQL-python
                    Error: Unable to find a match: MySQL-python
     Started: 03:06:57.804965
    Duration: 33111.198 ms
     Changes:

Steps to reproduce the bug

salt-call state.apply mysql

Holy Smokes! It's missing in the versions report and the python shell:

[root@3e477a6d4c63 /]# python3
Python 3.6.8 (default, Apr 16 2020, 01:36:27)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'MySQLdb'
>>>

Attempts to fix the bug

Best. but really awkward, solution seems to be:

dnf install mysql-devel
pip3 install mysqlclient

This means that mysql-python shows up in salt -V:

# salt -V
Salt Version:
           Salt: 3000.3

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: 0.35.2
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: 1.4.6
      pycparser: 2.14
       pycrypto: Not Installed
   pycryptodome: 3.9.7
         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.0
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.2

System Versions:
           dist: centos 8.1.1911 Core
         locale: UTF-8
        machine: x86_64
        release: 4.18.0-147.3.1.el8_1.x86_64
         system: Linux
        version: CentOS Linux 8.1.1911 Core

Now available in python shell:

# python3
Python 3.6.8 (default, Apr 16 2020, 01:36:27)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>

I'm happy to create a PR but not entirely sure what it should be right now. Note that this also affects mysql usage by salt generally (such as returners etc)

myii commented 4 years ago

Thanks for the detailed report, @campbellmc. I can confirm this from Travis:

As you've mentioned, the fix may be a little convoluted and there's no set maintainer for this formula at the current time. What's the actual package replacement for MySQL-python on CentOS 8?

campbellmc commented 4 years ago

The pypi package mysqlclient was the only package I could find that worked to provide python bindings. I didn't find a drop in replacement yum package that provides the MySQLdb python module. The pypi module PyMySQL seems to have more activity as a module, however, it's not detected by salt.

lmeerwood commented 4 years ago

@campbellmc did you end up reaching a solution for this? I am running in to the exact same issue.

campbellmc commented 4 years ago

@campbellmc did you end up reaching a solution for this? I am running in to the exact same issue.

Sadly, my solution involved not using salt for managing mysql.

noelmcloughlin commented 3 years ago

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