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

[BUG] mysql_user.present state broken on 3000: AttributeError: 'str' object has no attribute 'items' #56388

Closed
upya4ko opened this issue Mar 16, 2020 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE fixed-pls-verify fix is linked, bug author to confirm fix P3 Priority 3 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@upya4ko
Copy link

upya4ko commented Mar 16, 2020

Description of Issue

mysql_user.present state broken on 3000.

AttributeError: 'str' object has no attribute 'items'

This issue may be same as #51 but with normal description.

Steps to Reproduce Issue

test_user.sls based on example.

TEST_USER:
  mysql_user.present:
    - host: localhost
    - password: bobcat
root@MASTER:/# salt-call -l debug state.apply mysql.test_user test=true
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: MASTER.lan
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG   ] Grains refresh requested. Refreshing grains.
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] The `lspci` binary is not available on the system. GPU grains will not be available.
[DEBUG   ] LazyLoaded zfs.is_supported
[DEBUG   ] Connecting to master. Attempt 1 of 1
[DEBUG   ] "salt" Not an IP address? Assuming it is a hostname.
[DEBUG   ] Master URI: tcp://MASTER_IP:4506
[DEBUG   ] Initializing new AsyncAuth for ('/var/lib/salt/pki/minion', 'MASTER.lan', 'tcp://MASTER_IP:4506')
[DEBUG   ] Generated random reconnect delay between '1000ms' and '11000ms' (7085)
[DEBUG   ] Setting zmq_reconnect_ivl to '7085ms'
[DEBUG   ] Setting zmq_reconnect_ivl_max to '11000ms'
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/var/lib/salt/pki/minion', 'MASTER.lan', 'tcp://MASTER_IP:4506', 'clear')
[DEBUG   ] Connecting the Minion to the Master URI (for the return server): tcp://MASTER_IP:4506
[DEBUG   ] Trying to connect to: tcp://MASTER_IP:4506
[DEBUG   ] salt.crypt.get_rsa_pub_key: Loading public key
[DEBUG   ] Decrypting the current master AES key
[DEBUG   ] salt.crypt.get_rsa_key: Loading private key
[DEBUG   ] salt.crypt._get_key_with_evict: Loading private key
[DEBUG   ] Loaded minion key: /var/lib/salt/pki/minion/minion.pem
[DEBUG   ] salt.crypt.get_rsa_pub_key: Loading public key
[DEBUG   ] Closing AsyncZeroMQReqChannel instance
[DEBUG   ] Connecting the Minion to the Master publish port, using the URI: tcp://MASTER_IP:4505
[DEBUG   ] salt.crypt.get_rsa_key: Loading private key
[DEBUG   ] Loaded minion key: /var/lib/salt/pki/minion/minion.pem
[DEBUG   ] Determining pillar cache
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/var/lib/salt/pki/minion', 'MASTER.lan', 'tcp://MASTER_IP:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/var/lib/salt/pki/minion', 'MASTER.lan', 'tcp://MASTER_IP:4506')
[DEBUG   ] Connecting the Minion to the Master URI (for the return server): tcp://MASTER_IP:4506
[DEBUG   ] Trying to connect to: tcp://MASTER_IP:4506
[DEBUG   ] salt.crypt.get_rsa_key: Loading private key
[DEBUG   ] Loaded minion key: /var/lib/salt/pki/minion/minion.pem
[DEBUG   ] Closing AsyncZeroMQReqChannel instance
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded state.apply
[DEBUG   ] LazyLoaded direct_call.execute
[DEBUG   ] LazyLoaded saltutil.is_running
[DEBUG   ] LazyLoaded grains.get
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/var/lib/salt/pki/minion', 'MASTER.lan', 'tcp://MASTER_IP:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/var/lib/salt/pki/minion', 'MASTER.lan', 'tcp://MASTER_IP:4506')
[DEBUG   ] Connecting the Minion to the Master URI (for the return server): tcp://MASTER_IP:4506
[DEBUG   ] Trying to connect to: tcp://MASTER_IP:4506
[DEBUG   ] Gathering pillar data for state run
[DEBUG   ] Finished gathering pillar data for state run
[INFO    ] Loading fresh modules for state activity
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] In saltenv 'base', looking at rel_path 'mysql/test_user.sls' to resolve 'salt://mysql/test_user.sls'
[DEBUG   ] In saltenv 'base', ** considering ** path '/var/cache/salt/minion/files/base/mysql/test_user.sls' to resolve 'salt://mysql/test_user.sls'
[DEBUG   ] compile template: /var/cache/salt/minion/files/base/mysql/test_user.sls
[DEBUG   ] Jinja search path: ['/var/cache/salt/minion/files/base']
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/var/lib/salt/pki/minion', 'MASTER.lan', 'tcp://MASTER_IP:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/var/lib/salt/pki/minion', 'MASTER.lan', 'tcp://MASTER_IP:4506')
[DEBUG   ] Connecting the Minion to the Master URI (for the return server): tcp://MASTER_IP:4506
[DEBUG   ] Trying to connect to: tcp://MASTER_IP:4506
[PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/mysql/test_user.sls' using 'jinja' renderer: 0.0672142505645752
[DEBUG   ] Rendered data from file: /var/cache/salt/minion/files/base/mysql/test_user.sls:

TEST_USER:
  mysql_user.present:
    - host: localhost
    - password: bobcat

[DEBUG   ] Results of YAML rendering:
OrderedDict([('TEST_USER', OrderedDict([('mysql_user.present', [OrderedDict([('host', 'localhost')]), OrderedDict([('password', 'bobcat')])])]))])
[PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/mysql/test_user.sls' using 'yaml' renderer: 0.0019073486328125
[DEBUG   ] LazyLoaded config.option
[DEBUG   ] LazyLoaded mysql.user_create
[DEBUG   ] LazyLoaded mysql_user.present
[INFO    ] Running state [TEST_USER] at time 15:40:17.276603
[INFO    ] Executing state mysql_user.present for [TEST_USER]
[DEBUG   ] An exception occurred in this state: 'str' object has no attribute 'items'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/state.py", line 1981, in call
    **cdata['kwargs'])
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 1977, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/states/mysql_user.py", line 142, in present
    **connection_args):
  File "/usr/lib/python3/dist-packages/salt/modules/mysql.py", line 1266, in user_exists
    server_version = salt.utils.data.decode(version(**connection_args))
  File "/usr/lib/python3/dist-packages/salt/modules/mysql.py", line 858, in version
    dbc = _connect(**connection_args)
  File "/usr/lib/python3/dist-packages/salt/modules/mysql.py", line 392, in _connect
    dbc = MySQLdb.connect(**connargs)
  File "/usr/lib/python3/dist-packages/MySQLdb/__init__.py", line 86, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 172, in __init__
    for k, v in conv.items():
AttributeError: 'str' object has no attribute 'items'
[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/state.py", line 1981, in call
    **cdata['kwargs'])
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 1977, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/states/mysql_user.py", line 142, in present
    **connection_args):
  File "/usr/lib/python3/dist-packages/salt/modules/mysql.py", line 1266, in user_exists
    server_version = salt.utils.data.decode(version(**connection_args))
  File "/usr/lib/python3/dist-packages/salt/modules/mysql.py", line 858, in version
    dbc = _connect(**connection_args)
  File "/usr/lib/python3/dist-packages/salt/modules/mysql.py", line 392, in _connect
    dbc = MySQLdb.connect(**connargs)
  File "/usr/lib/python3/dist-packages/MySQLdb/__init__.py", line 86, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 172, in __init__
    for k, v in conv.items():
AttributeError: 'str' object has no attribute 'items'

[INFO    ] Completed state [TEST_USER] at time 15:40:17.291434 (duration_in_ms=14.831)
[DEBUG   ] File /var/cache/salt/minion/accumulator/3005419212 does not exist, no need to cleanup
[DEBUG   ] LazyLoaded config.option
[DEBUG   ] LazyLoaded state.check_result
[DEBUG   ] Closing AsyncZeroMQReqChannel instance
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/var/lib/salt/pki/minion', 'MASTER.lan', 'tcp://MASTER_IP:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/var/lib/salt/pki/minion', 'MASTER.lan', 'tcp://MASTER_IP:4506')
[DEBUG   ] Connecting the Minion to the Master URI (for the return server): tcp://MASTER_IP:4506
[DEBUG   ] Trying to connect to: tcp://MASTER_IP:4506
[DEBUG   ] Closing AsyncZeroMQReqChannel instance
[DEBUG   ] LazyLoaded highstate.output
local:
----------
          ID: TEST_USER
    Function: mysql_user.present
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python3/dist-packages/salt/state.py", line 1981, in call
                  **cdata['kwargs'])
                File "/usr/lib/python3/dist-packages/salt/loader.py", line 1977, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python3/dist-packages/salt/states/mysql_user.py", line 142, in present
                  **connection_args):
                File "/usr/lib/python3/dist-packages/salt/modules/mysql.py", line 1266, in user_exists
                  server_version = salt.utils.data.decode(version(**connection_args))
                File "/usr/lib/python3/dist-packages/salt/modules/mysql.py", line 858, in version
                  dbc = _connect(**connection_args)
                File "/usr/lib/python3/dist-packages/salt/modules/mysql.py", line 392, in _connect
                  dbc = MySQLdb.connect(**connargs)
                File "/usr/lib/python3/dist-packages/MySQLdb/__init__.py", line 86, in Connect
                  return Connection(*args, **kwargs)
                File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 172, in __init__
                  for k, v in conv.items():
              AttributeError: 'str' object has no attribute 'items'
     Started: 15:40:17.276603
    Duration: 14.831 ms
     Changes:

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:  14.831 ms
[DEBUG   ] Closing AsyncZeroMQReqChannel instance

Versions Report Master and Minion (same server)

Salt Version:
           Salt: 3000

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.7.3
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 2.10
        libgit2: 0.27.7
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: 1.3.10
      pycparser: 2.19
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.27.4
         Python: 3.7.3 (default, Dec 20 2019, 18:57:59)
   python-gnupg: Not Installed
         PyYAML: 3.13
          PyZMQ: 17.1.2
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.1

System Versions:
           dist: debian 10.3
         locale: UTF-8
        machine: i686
        release: 4.19.0-8-686-pae
         system: Linux
        version: debian 10.3

More info:

python3-mysqldb:
  Installed: 1.3.10-2
  Candidate: 1.3.10-2

salt-minion:
  Installed: 3000+dfsg1-3
  Candidate: 3000+dfsg1-3

salt-master:
  Installed: 3000+dfsg1-3
  Candidate: 3000+dfsg1-3
@upya4ko upya4ko changed the title mysql_user.present state broken on 3000: AttributeError: 'str' object has no attribute 'items' [BUG] mysql_user.present state broken on 3000: AttributeError: 'str' object has no attribute 'items' Mar 16, 2020
@frogunder frogunder added this to the Approved milestone Mar 16, 2020
@frogunder frogunder added Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P3 Priority 3 labels Mar 16, 2020
@frogunder
Copy link
Contributor

@McPcholkin Thank you for reporting this issue.

I see the same thing.

Thanks.

@frogunder
Copy link
Contributor

Actually this might be fixed with #56174 which will be in 3000.1.

@garethgreenaway maybe you can confirm that or not?

@garethgreenaway
Copy link
Contributor

@frogunder Yup! This issue will be fixed by that PR and will be available in 3000.1.

@frogunder frogunder added the fixed-pls-verify fix is linked, bug author to confirm fix label Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE fixed-pls-verify fix is linked, bug author to confirm fix P3 Priority 3 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

No branches or pull requests

4 participants