salt icon indicating copy to clipboard operation
salt copied to clipboard

KeyError: 'saltutil.is_running' on 2015.8.1

Open scottleibrand opened this issue 11 years ago • 24 comments

I just upgraded my salt-master and one salt-minion to 2015.8.1 to troubleshoot https://github.com/saltstack/salt/issues/27414 with @rallytime, and noticed a new error when trying to run commands like salt phx1-1 state.highstate:

root@phx1-8:/srv/salt# salt phx1-1 state.highstate
phx1-1:
    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1161, in _thread_return
        data['arg'][ind],
      File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 498, in highstate
        conflict = _check_queue(queue, kwargs)
      File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 156, in _check_queue
        conflict = running()
      File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 119, in running
        active = __salt__['saltutil.is_running']('state.*')
      File "/usr/lib/python2.7/dist-packages/salt/utils/lazy.py", line 90, in __getitem__
        return self._dict[key]
    KeyError: 'saltutil.is_running'
root@phx1-8:/srv/salt#

Based on the minion logs, it does seem to actually execute the requested highstate, but never returns any output to the master that made the request.

If I execute the same commands locally on the minion using salt-call, I don't see this issue.

Is this a known issue? Am I doing something wrong with my upgrade process? (I followed https://docs.saltstack.com/en/latest/topics/installation/ubuntu.html).

root@phx1-8:/srv/salt# salt --versions-report
Salt Version:
           Salt: 2015.8.1

Dependency Versions:
         Jinja2: 2.7.2
       M2Crypto: 0.21.1
           Mako: 0.9.1
         PyYAML: 3.10
          PyZMQ: 14.4.0
         Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.4
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.5
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.3.0
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: 0.8.2
        timelib: Not Installed

System Versions:
           dist: Ubuntu 14.04 trusty
        machine: x86_64
        release: 3.16.0-48-generic
         system: Ubuntu 14.04 trusty
scott@phx1-1:/var/log/salt$ salt-minion --versions-report
Salt Version:
           Salt: 2015.8.1

Dependency Versions:
         Jinja2: 2.7.2
       M2Crypto: 0.21.1
           Mako: 0.9.1
         PyYAML: 3.10
          PyZMQ: 14.4.0
         Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.4
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.5
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.3.0
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: 0.8.2
        timelib: Not Installed

System Versions:
           dist: Ubuntu 14.04 trusty
        machine: x86_64
        release: 3.16.0-45-generic
         system: Ubuntu 14.04 trusty

scottleibrand avatar Oct 23 '15 23:10 scottleibrand

@scottleibrand, thanks for the report.

jfindlay avatar Oct 26 '15 17:10 jfindlay

Can confirm the same on Debian Wheezy, 2015.8.1. In my case, I am trying to use reactor to report job failures to a slack channel, and the sls that's supposed to send the slack message fails with this same error.

In my case, the sls looks like this after its been rendered by reactor:

{% set fun:        "state.sls"  %}
{% set fun_args:   "['testing.brokensls']" %}
{% set id:         "web03-website-staging" %}
{% set jid:        "20151026140032975692" %}
{% set timestamp:  "2015-10-26T18:00:33.303387" %}
{% set return:     |
    "{'file_|-this_state_should_fail_|-/tmp/no_such_file.txt_|-absent': {'comment': "Could not remove '/tmp/no_such_file.txt': [Errno 1] Operation not permitted: '/tmp/no_such_file.txt'", 'name': '/tmp/no_such_file.txt', 'start_time': '14:00:14.883738', 'result': False, 'duration': 5.648, '__run_num__': 0, 'changes': {}}}" %}

job_failure_notify_slack:
  slack.post_message:
    - channel:   alerts-testing
    - from_name: salt-master
    - api_key:   my-api-key
    - message:   |
        Job failure event on {{ id }} at {{ timestamp }} for `{{ fun_args }}`. Error(s) reported:  `{{ return }}`

If I try running this sls manually with -l debug, it results in the same error:

[DEBUG   ] Reading configuration from /etc/salt/master
[DEBUG   ] Including configuration from '/etc/salt/master.d/api.conf'
[DEBUG   ] Reading configuration from /etc/salt/master.d/api.conf
[DEBUG   ] Including configuration from '/etc/salt/master.d/master.conf'
[DEBUG   ] Reading configuration from /etc/salt/master.d/master.conf
[DEBUG   ] Including configuration from '/etc/salt/master.d/reactor.conf'
[DEBUG   ] Reading configuration from /etc/salt/master.d/reactor.conf
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: salt-master
[DEBUG   ] Missing configuration file: /root/.saltrc
[DEBUG   ] Configuration file path: /etc/salt/master
[DEBUG   ] Reading configuration from /etc/salt/master
[DEBUG   ] Including configuration from '/etc/salt/master.d/api.conf'
[DEBUG   ] Reading configuration from /etc/salt/master.d/api.conf
[DEBUG   ] Including configuration from '/etc/salt/master.d/master.conf'
[DEBUG   ] Reading configuration from /etc/salt/master.d/master.conf
[DEBUG   ] Including configuration from '/etc/salt/master.d/reactor.conf'
[DEBUG   ] Reading configuration from /etc/salt/master.d/reactor.conf
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: salt-master
[DEBUG   ] Missing configuration file: /root/.saltrc
[DEBUG   ] MasterEvent PUB socket URI: ipc:///var/run/salt/master/master_event_pub.ipc
[DEBUG   ] MasterEvent PULL socket URI: ipc:///var/run/salt/master/master_event_pull.ipc
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'salt-master_master', 'tcp://127.0.0.1:4506', 'clear')
[DEBUG   ] LazyLoaded local_cache.get_load
[DEBUG   ] get_iter_returns for jid 20151026140924851302 sent to set(['salt-master']) will timeout at 14:10:24.860707
[DEBUG   ] jid 20151026140924851302 return from salt-master
[DEBUG   ] LazyLoaded nested.output
salt-master:
    The minion function caused an exception: Traceback (most recent call last):
      File "/var/src/salt/local/lib/python2.7/site-packages/salt/minion.py", line 1146, in _thread_return
        ret['ret_config'] = data['ret_config']
      File "/var/src/salt/local/lib/python2.7/site-packages/salt/modules/state.py", line 641, in sls
        conflict = running(concurrent)
      File "/var/src/salt/local/lib/python2.7/site-packages/salt/modules/state.py", line 119, in running
        active = __salt__['saltutil.is_running']('state.*')
      File "/var/src/salt/local/lib/python2.7/site-packages/salt/utils/lazy.py", line 90, in __getitem__
        return self._dict[key]
    KeyError: 'saltutil.is_running'
salt-master --versions-report
Salt Version:
           Salt: 2015.8.1

Dependency Versions:
         Jinja2: 2.8
       M2Crypto: 0.22
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.7.0
         Python: 2.7.3 (default, Mar 13 2014, 11:03:55)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.4
           cffi: 1.1.2
       cherrypy: 3.7.0
       dateutil: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: debian 7.8 
        machine: x86_64
        release: 3.2.0-4-amd64
         system: debian 7.8 
salt-minion --versions-report
Salt Version:
           Salt: 2015.8.1

Dependency Versions:
         Jinja2: 2.8
       M2Crypto: 0.22
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.7.0
         Python: 2.7.3 (default, Mar 13 2014, 11:03:55)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.4
           cffi: 1.1.2
       cherrypy: 3.7.0
       dateutil: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: debian 7.8 
        machine: x86_64
        release: 3.2.0-4-amd64
         system: debian 7.8 

ksmitdevops avatar Oct 26 '15 18:10 ksmitdevops

I can't seem to replicate this. Are these errors happening consistently or are they intermitent? If they're consistent, is there a highstate that does not produce this? Basically, I'm looking for a way to try and reproduce this here locally. Any suggestions are welcome.

cachedout avatar Oct 27 '15 16:10 cachedout

They're consistent (100% of the time) for me. Running both highstate and state.apply always triggers it. Not sure what is different about our environment, but happy to run any diagnostics you need.

scottleibrand avatar Oct 27 '15 18:10 scottleibrand

@scottleibrand Does it happen even with a minimal test case? i.e. a top.sls that only fires a minimal set of states?

cachedout avatar Oct 27 '15 19:10 cachedout

I tried it with a minimal state.apply, but not a minimal top.sls. I'll try that and let you know.

scottleibrand avatar Oct 27 '15 23:10 scottleibrand

@scottleibrand Sounds good. Anything we can do to figure out what it takes for others to reliably reproduce this will be immensly helpful. Thanks!

cachedout avatar Oct 28 '15 03:10 cachedout

Still happens even with the simplest possible top.sls:

root@phx1-8:/srv/salt# cat top.sls
base:
  '*':
    - upgrade-all
root@phx1-8:/srv/salt# cat upgrade-all.sls
pkg.upgrade:
  module.run:
    - refresh: True
root@phx1-8:/srv/salt# salt phx1-8 state.highstate
phx1-8:
    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1161, in _thread_return
        data['arg'][ind],
      File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 498, in highstate
        conflict = _check_queue(queue, kwargs)
      File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 156, in _check_queue
        conflict = running()
      File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 119, in running
        active = __salt__['saltutil.is_running']('state.*')
      File "/usr/lib/python2.7/dist-packages/salt/utils/lazy.py", line 90, in __getitem__
        return self._dict[key]
    KeyError: 'saltutil.is_running'

scottleibrand avatar Oct 28 '15 23:10 scottleibrand

@scottjpack How odd. Anything else that might be coming into play here? Custom modules/grains? An exception happening in pillar compilation? I'm just trying to figure out what's causing this on your side when we can't see it here at all.

cachedout avatar Oct 29 '15 19:10 cachedout

@cachedout @scottleibrand I get same issue:

    `The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1161, in _thread_return
        ret = {
      File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 655, in sls
        conflict = running(concurrent)
      File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 119, in running
        active = __salt__['saltutil.is_running']('state.*')
      File "/usr/lib/python2.7/dist-packages/salt/utils/lazy.py", line 90, in __getitem__
        return self._dict[key]
    KeyError: 'saltutil.is_running'`

When I start investigate this, I found that multiple minions are running on same host:

salt '*' cmd.run "salt-minion --version"

minion1:
    salt-minion 2015.8.3 (Beryllium)

minion1:
    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1161, in _thread_return
        ret = {
      File "/usr/lib/python2.7/dist-packages/salt/modules/cmdmod.py", line 803, in run
        use_vt=use_vt)
      File "/usr/lib/python2.7/dist-packages/salt/modules/cmdmod.py", line 454, in _run
        out = salt.utils.to_str(out).rstrip()
    AttributeError: 'module' object has no attribute 'to_str'
ps aux|grep salt

root     22967  0.0  0.0 137692 19416 ?        Ss   12:15   0:00 /usr/bin/python /usr/bin/salt-minion
root     22994  0.1  0.0 541468 27644 ?        Sl   12:15   0:00 /usr/bin/python /usr/bin/salt-minion
root     27017  0.0  0.0 366776 26088 ?        Sl   дек.01   7:21 /usr/bin/python /usr/bin/salt-minion -d

And salt '*' cmd.run "killall -9 salt-minion; service salt-minion start" is solved my problem

axmetishe avatar Dec 12 '15 09:12 axmetishe

@scottleibrand By chance can you confirm what @axmetishe is seeing?

cachedout avatar Jun 03 '16 21:06 cachedout

I ended up reverting (I think) and was never in a position to try to reproduce further.

scottleibrand avatar Jun 06 '16 02:06 scottleibrand

+1 Am seeing this immediatly after upgrading from 2015.8.3 to 2016.3.0 but after the initial error it works correctly so it is had to replicate.

akissa avatar Jun 13 '16 09:06 akissa

P.S am calling salt from another python application so i do not have the full traceback to investigate further

akissa avatar Jun 13 '16 09:06 akissa

This looks to be related to https://github.com/saltstack/salt/issues/34043

l2ol33rt avatar Jun 17 '16 21:06 l2ol33rt

+1, same problem here after an upgrade.

After reading #34043 I manually installed Python psutil and the error has gone away: yum install python-psutil. Not sure if I should use yum to install the package but it's done the trick for now.

oliver-dungey avatar Aug 10 '16 10:08 oliver-dungey

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Jun 15 '18 17:06 stale[bot]

I'm seeing this on 2017.7.8

Mrten avatar Oct 25 '18 09:10 Mrten

both when running state.highstate and a single state.sls

Mrten avatar Oct 25 '18 10:10 Mrten

only a problem when the minion is 2017.7.8, 2017.7.7 minions work OK

Mrten avatar Oct 25 '18 10:10 Mrten