salt icon indicating copy to clipboard operation
salt copied to clipboard

Error when running most Salt commands on 2015.2 with MySQL entries in /etc/salt/master

Open ssgward opened this issue 11 years ago • 9 comments

Running latest 2015.2 SHA.

/etc/salt/master has the following entries that could be contributing to this error. I'm guessing it's the mysql entires that are the problem:

rest_cherrypy:
  port: 8000
  disable_ssl: True
  debug: True


# Please replace mysql.host by your hostname (real data removed for security)
mysql.host: 'x.x.x.x'
mysql.user: 'xxxxx'
mysql.pass: 'xxxxx'
mysql.db: 'xxxx'

master_job_cache: mysql

event_return: mysql

loop_interval: 5
presence_events: True

id: 2

This particular server is not running a MySQL DB, but is pointing to another master that has MySQL installed.

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
OperationalError: (2003, "Can't connect to MySQL server on 'x.x.x.x' (111)")
Traceback (most recent call last):
  File "/usr/bin/salt", line 10, in <module>
    salt_main()
  File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 240, in salt_main
    client.run()
  File "/usr/lib/python2.7/dist-packages/salt/cli/__init__.py", line 186, in run
    for full_ret in cmd_func(**kwargs):
  File "/usr/lib/python2.7/dist-packages/salt/client/__init__.py", line 584, in cmd_cli
    **kwargs):
  File "/usr/lib/python2.7/dist-packages/salt/client/__init__.py", line 1206, in get_cli_event_returns
    expect_minions=(verbose or show_timeout)
  File "/usr/lib/python2.7/dist-packages/salt/client/__init__.py", line 843, in get_iter_returns
    if self.returners['{0}.get_load'.format(self.opts['master_job_cache'])](jid) == {}:
  File "/usr/lib/python2.7/dist-packages/salt/returners/mysql.py", line 181, in get_load
    with _get_serv(commit=True) as cur:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/lib/python2.7/dist-packages/salt/returners/mysql.py", line 130, in _get_serv
    port=_options['port'])
  File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on 'x.x.x.x' (111)")
Traceback (most recent call last):
  File "/usr/bin/salt", line 10, in <module>
    salt_main()
  File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 240, in salt_main
    client.run()
  File "/usr/lib/python2.7/dist-packages/salt/cli/__init__.py", line 186, in run
    for full_ret in cmd_func(**kwargs):
  File "/usr/lib/python2.7/dist-packages/salt/client/__init__.py", line 584, in cmd_cli
    **kwargs):
  File "/usr/lib/python2.7/dist-packages/salt/client/__init__.py", line 1206, in get_cli_event_returns
    expect_minions=(verbose or show_timeout)
  File "/usr/lib/python2.7/dist-packages/salt/client/__init__.py", line 843, in get_iter_returns
    if self.returners['{0}.get_load'.format(self.opts['master_job_cache'])](jid) == {}:
  File "/usr/lib/python2.7/dist-packages/salt/returners/mysql.py", line 181, in get_load
    with _get_serv(commit=True) as cur:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/lib/python2.7/dist-packages/salt/returners/mysql.py", line 130, in _get_serv
    port=_options['port'])
  File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'x.x.x.x' (111)")

As simple salt '*' test.ping will expose the error.

ssgward avatar Feb 27 '15 22:02 ssgward

@ssgward Is there a typo in the configuration entries above? Should

event_retrun: mysql

be

event_return: mysql

cro avatar Feb 28 '15 19:02 cro

@cro - correct. There was a typo and it should be as you mentioned. I've corrected the original comment

ssgward avatar Mar 09 '15 17:03 ssgward

So it's broke even with the fixed typo, right?

--cro

From: ssgward [email protected] Reply: saltstack/salt [email protected]> Date: March 9, 2015 at 11:08:57 AM To: saltstack/salt [email protected]> Cc: C. R. Oldham [email protected]> Subject:  Re: [salt] Error when running most Salt commands on 2015.2 with MySQL entries in /etc/salt/master (#21138)

@cro - correct. There was a typo and it should be as you mentioned. I've corrected the original comment

— Reply to this email directly or view it on GitHub.

cro avatar Mar 09 '15 17:03 cro

Correct.

ssgward avatar Mar 09 '15 17:03 ssgward

Here's an additional error that was in /var/log/salt/master that may or may not help with fixing this issue:

2015-03-11 15:01:23,386 [salt.master      ][CRITICAL][3606] Unexpected Error in Mworker
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/master.py", line 715, in __bind
    ret = self.serial.dumps(self._handle_payload(payload))
  File "/usr/lib/python2.7/dist-packages/salt/master.py", line 766, in _handle_payload
    'clear': self._handle_clear}[key](load)
  File "/usr/lib/python2.7/dist-packages/salt/master.py", line 779, in _handle_clear
    return getattr(self.clear_funcs, load['cmd'])(load)
  File "/usr/lib/python2.7/dist-packages/salt/master.py", line 2352, in publish
    clear_load['jid'] = self.mminion.returners[fstr](nocache=extra.get('nocache', False),
  File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 873, in __getitem__
    mod = super(LazyLoader, self).__getitem__(key)
  File "/usr/lib/python2.7/dist-packages/salt/utils/lazy.py", line 95, in __getitem__
    raise KeyError(key)
KeyError: 'mysql.prep_jid'

ssgward avatar Mar 11 '15 17:03 ssgward

@cachedout - We don't get the exception any more. That is taken care of. We now get this message:

[ERROR   ] Salt request timed out. If this error persists, worker_threads may need to be increased.
Failed to authenticate!  This is most likely because this user is not permitted to execute commands, but there is a small possibility that a disk error occurred (check disk/inode usage).

Users can still not run any basic commands in salt, however. A test.ping will never run, for example.

ssgward avatar Mar 11 '15 21:03 ssgward

salt-run manage.status produces the following:

[root@salt2 ~]# salt-run manage.status
[ERROR   ] Salt request timed out. If this error persists, worker_threads may need to be increased.
Exception occurred in runner manage.status: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/client/mixins.py", line 317, in low
    data['return'] = self.functions[fun](*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/runners/manage.py", line 42, in status
    minions = client.cmd('*', 'test.ping', timeout=__opts__['timeout'])
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 518, in cmd
    **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 276, in run_job
    return self._check_pub_data(pub_data)
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 211, in _check_pub_data
    'Failed to authenticate!  This is most likely because this '
EauthAuthenticationError: Failed to authenticate!  This is most likely because this user is not permitted to execute commands, but there is a small possibility that a disk error occurred (check disk/inode usage).

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
KeyError: 'mysql.prep_jid'
Traceback (most recent call last):
  File "/bin/salt-run", line 10, in <module>
    salt_run()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 243, in salt_run
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/run.py", line 54, in run
    runner.run()
  File "/usr/lib/python2.7/site-packages/salt/runner.py", line 165, in run
    False)  # Don't daemonize
  File "/usr/lib/python2.7/site-packages/salt/client/mixins.py", line 381, in _proc_function
    return self.low(fun, low)
  File "/usr/lib/python2.7/site-packages/salt/client/mixins.py", line 336, in low
    mminion=self.mminion,
  File "/usr/lib/python2.7/site-packages/salt/utils/job.py", line 35, in store_job
    mminion.returners[jidstore_fstr](False, passed_jid=load['jid'])
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 873, in __getitem__
    mod = super(LazyLoader, self).__getitem__(key)
  File "/usr/lib/python2.7/site-packages/salt/utils/lazy.py", line 95, in __getitem__
    raise KeyError(key)
KeyError: 'mysql.prep_jid'
Traceback (most recent call last):
  File "/bin/salt-run", line 10, in <module>
    salt_run()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 243, in salt_run
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/run.py", line 54, in run
    runner.run()
  File "/usr/lib/python2.7/site-packages/salt/runner.py", line 165, in run
    False)  # Don't daemonize
  File "/usr/lib/python2.7/site-packages/salt/client/mixins.py", line 381, in _proc_function
    return self.low(fun, low)
  File "/usr/lib/python2.7/site-packages/salt/client/mixins.py", line 336, in low
    mminion=self.mminion,
  File "/usr/lib/python2.7/site-packages/salt/utils/job.py", line 35, in store_job
    mminion.returners[jidstore_fstr](False, passed_jid=load['jid'])
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 873, in __getitem__
    mod = super(LazyLoader, self).__getitem__(key)
  File "/usr/lib/python2.7/site-packages/salt/utils/lazy.py", line 95, in __getitem__
    raise KeyError(key)
KeyError: 'mysql.prep_jid'

ssgward avatar Mar 11 '15 21:03 ssgward

Commands can be run via salt-call and run with out problem.

ssgward avatar Mar 11 '15 21:03 ssgward

This has been fixed. Closing.

ssgward avatar Mar 17 '15 23:03 ssgward