Skip to content

Orchestration gives exception when a target does not exist #32479

Closed

Description

@ssgward

Orchestration/state.orchestrate gives exception when a target listed in the orchestration file does not exist.

Expecting that the exception would be handled and a helpful message displayed instead.

Here's an example orchestration file being used. In this case the target 'app*' does not exist in the environment.
orch.sls

htop:
  salt.state:
    - tgt: 'app*'
    - sls:
      - htop

install_vim:
 salt.state:
   - tgt: '*'
   - sls:
     - vim

cmd.run:
  salt.function:
    - tgt: '*'
    - arg:
      - rm -rf /tmp/foo  

Steps to Reproduce Issue

  1. Run the above listed orchestration file in an env where the target of app* does not exist.
  2. Here is the command being run: salt-run state.orchestrate orchestrate.orch
  3. The following exception is printed to the screen:
No minions matched the target. No command was sent, no jid was assigned.
[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/state.py", line 1703, in call
    **cdata['kwargs'])
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1649, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/states/saltmod.py", line 225, in state
    cmd_ret = __salt__['saltutil.cmd'](tgt, fun, **cmd_kw)
  File "/usr/lib/python2.7/site-packages/salt/modules/saltutil.py", line 894, in cmd
    client, tgt, fun, arg, timeout, expr_form, ret, kwarg, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/modules/saltutil.py", line 862, in _exec
    for ret_comp in _cmd(**cmd_kwargs):
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 686, in cmd_iter
    self._clean_up_subscriptions(pub_data['jid'])
KeyError: 'jid'
  1. Keep in mind that the other states listed in the orchestration file get run due to the target '*' and if the target app* does exist there are no errors.
Salt Version:
           Salt: 2016.3.0rc2

Dependency Versions:
         Jinja2: 2.7.2
       M2Crypto: 0.21.1
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.7.0
         Python: 2.7.5 (default, Jun 17 2014, 18:11:42)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.7
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: centos 7.0.1406 Core
        machine: x86_64
        release: 3.10.0-123.el7.x86_64
         system: Linux
        version: CentOS Linux 7.0.1406 Core

Activity

  1. added
    bug
    severity-medium
    Core
    P2
    on Apr 11, 2016
  2. added this to the Approved milestone on Apr 11, 2016
  3. added a commit that references this issue on Apr 11, 2016
    9dadd74
  4. cachedout commented on Apr 11, 2016

    @cachedout
    Contributor

    Really good find here.

  5. added
    fixed-pls-verify
    on Apr 11, 2016
  6. ssgward commented on Apr 11, 2016

    @ssgward
    Author

    Nice. Quick fix. Verified the fix from head of 2016.3 on commit beginning with 20bbabb. Closing.

  7. added a commit that references this issue on Apr 11, 2016
    216d9fd
  8. beelit94 commented on May 24, 2016

    @beelit94

    I'm seeing the same error in 2015.8.10

    ----------
              ID: universal_forwarder_setup
        Function: salt.state
          Result: False
         Comment: An exception occurred in this state: Traceback (most recent call last):
                    File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1624, in call
                      **cdata['kwargs'])
                    File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1492, in wrapper
                      return f(*args, **kwargs)
                    File "/usr/lib/python2.7/dist-packages/salt/states/saltmod.py", line 221, in state
                      cmd_ret = __salt__['saltutil.cmd'](tgt, fun, **cmd_kw)
                    File "/usr/lib/python2.7/dist-packages/salt/modules/saltutil.py", line 911, in cmd
                      client, tgt, fun, arg, timeout, expr_form, ret, kwarg, **kwargs)
                    File "/usr/lib/python2.7/dist-packages/salt/modules/saltutil.py", line 879, in _exec
                      tgt, fun, arg, timeout, expr_form, ret, kwarg, **kwargs):
                    File "/usr/lib/python2.7/dist-packages/salt/client/__init__.py", line 663, in cmd_iter
                      self._clean_up_subscriptions(pub_data['jid'])
                  KeyError: 'jid'
         Started: 09:09:05.075580
        Duration: 31.486 ms
         Changes:
    
    Salt Version:
               Salt: 2015.8.10
    
    Dependency Versions:
             Jinja2: 2.7.2
           M2Crypto: 0.21.1
               Mako: Not Installed
             PyYAML: 3.10
              PyZMQ: 14.0.1
             Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
               RAET: Not Installed
            Tornado: 4.3
                ZMQ: 4.0.4
               cffi: Not Installed
           cherrypy: Not Installed
           dateutil: 2.5.3
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
            libgit2: Not Installed
            libnacl: Not Installed
       msgpack-pure: Not Installed
     msgpack-python: 0.3.0
       mysql-python: Not Installed
          pycparser: Not Installed
           pycrypto: 2.6.1
             pygit2: Not Installed
       python-gnupg: Not Installed
              smmap: Not Installed
            timelib: Not Installed
    
    System Versions:
               dist: Ubuntu 14.04 trusty
            machine: x86_64
            release: 3.13.0-48-generic
             system: Ubuntu 14.04 trusty
    
  9. ssgward commented on May 24, 2016

    @ssgward
    Author

    Yeah, this is fixed in 2016.3 branch, but needs to get back ported to the 2015.8 branch.

    @rallytime

  10. added a commit that references this issue on May 24, 2016
    042f17e
  11. added a commit that references this issue on Jun 1, 2016
    5a06245
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreP2bugfixed-pls-verifyseverity-medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions