Salt: Slack engine salt-run commands return exceptions

Created on 3 Apr 2019  路  7Comments  路  Source: saltstack/salt

Description of Issue/Question

salt.run commands return errors when run from Slack with the Slack Engine enabled on the master.

Discovered this when reviewing a related issue: #39783.

Setup

/etc/salt/master.d/engines.conf:

engines:
  - slack:
      token: 'xoxb-####'
      control: True
      fire_all: False
      groups:
        default:
          users:
            - '*'
          commands:
            - '*'
          default_target:
            target: localhost
            tgt_type: glob

/srv/salt/orch/get-os.sls:

get-os:
  salt.function:
    - name: grains.get
    - tgt: '*'
    - arg: 
      - os

Steps to Reproduce Issue

Attempt to run a runner function from Slack after configuring a bot:

!state.orchestrate orch.get-os

job `['state.orchestrate', 'orch.get-os']` (id: 20190402225400193489) (target: {'target': 'localhost', 'tgt_type': 'glob'}) returned

meanmachine_master:
    ----------
    fun:
        runner.state.orchestrate
    jid:
        20190402225400193489
    return:
        Exception occurred in runner state.orchestrate: Traceback (most recent call last):
          File "/usr/local/lib/python3.6/dist-packages/salt/client/mixins.py", line 364, in low
            expected_extra_kws=CLIENT_INTERNAL_KEYWORDS
          File "/usr/local/lib/python3.6/dist-packages/salt/utils/args.py", line 455, in format_call
            used_args_count
        salt.exceptions.SaltInvocationError: orchestrate takes at least 1 argument (0 given)
    success:
        False
    user:
        UNKNOWN
!jobs.active

job `['jobs.active']` (id: 20190402230245886369) (target: {'target': 'localhost', 'tgt_type': 'glob'}) returned

meanmachine_master:
    ----------
    fun:
        runner.jobs.active
    jid:
        20190402230245886369
    return:
        Exception occurred in runner jobs.active: Traceback (most recent call last):
          File "/usr/local/lib/python3.6/dist-packages/salt/client/mixins.py", line 364, in low
            expected_extra_kws=CLIENT_INTERNAL_KEYWORDS
          File "/usr/local/lib/python3.6/dist-packages/salt/utils/args.py", line 505, in format_call
            raise SaltInvocationError(msg)
        salt.exceptions.SaltInvocationError: 'args' and 'kwargs' are invalid keyword arguments for 'salt.loaded.int.runners.jobs.active'
    success:
        False
    user:
        UNKNOWN

Versions Report

Salt Version:
           Salt: 2019.2.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: 2.0.3
      gitpython: 2.1.8
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.6.1
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.7 (default, Oct 22 2018, 11:32:17)
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.3
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.5

System Versions:
           dist: Ubuntu 18.04 bionic
         locale: UTF-8
        machine: x86_64
        release: 4.19.11-041911-generic
         system: Linux
        version: Ubuntu 18.04 bionic
Bug Confirmed severity-medium

All 7 comments

looks like we need to fix this up. Thanks @olipovch

Do you know if this was occurring in previous salt versions as well?

I can confirm that I see the same issue in 2019.2.0 and it is not present in 2018.3.4:

Salt Slack.Engine: (This is the constant between both versions)

    engines:
      - slack:
          trigger: "test!"
          token: 'xoxb-xxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxx'
          control: True
          fire_all: False
          groups:
            default:
              users:
                - rob.jones
              commands:
                - help
                - show_updates
              aliases:
                show_updates:
                  type: runner
                  cmd: aqstack.show_updates
                help:
                  type: runner
                  cmd: aqstack.test_help
              default_target:
                target: saltmaster01.test.aquto.internal
                tgt_type: glob

2019.2.0 - Salt Version

Salt Version:
           Salt: 2019.2.0

Dependency Versions:
           cffi: 1.12.3
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: 0.26.6
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.19
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.26.4
         Python: 2.7.5 (default, Apr  9 2019, 14:30:50)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.6.1810 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-862.2.3.el7.x86_64
         system: Linux
        version: CentOS Linux 7.6.1810 Core

2019.2.0 - Slack Output

test!help

salt APP [4:28 PM]
@rob.jones's job is submitted as salt jid 20190425202829608155
@rob.jones's job `[u'aqstack.test_help']` (id: 20190425202829608155) (target: {u'tgt_type': u'pillar', u'target': u'saltmaster01.test.aquto.internal'}) returned
salt-results-20190425202832183140 
saltmaster01.test.aquto.internal_master:
  ----------
  fun:
    runner.aqstack.test_help
  jid:
    20190425202829608155
  return:
    Exception occurred in runner aqstack.test_help: Traceback (most recent call last):
     File "/usr/lib/python2.7/site-packages/salt/client/mixins.py", line 364, in low
      expected_extra_kws=CLIENT_INTERNAL_KEYWORDS
     File "/usr/lib/python2.7/site-packages/salt/utils/args.py", line 505, in format_call
      raise SaltInvocationError(msg)
    SaltInvocationError: 'args' and 'kwargs' are invalid keyword arguments for 'salt.loaded.ext.runners.aqstack.test_help'
  success:
    False
  user:
    UNKNOWN

2018.3.4 - Salt Version

Salt Version:
           Salt: 2018.3.4

Dependency Versions:
           cffi: 1.12.3
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: 0.26.6
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.19
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.26.4
         Python: 2.7.5 (default, Apr  9 2019, 14:30:50)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.6.1810 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-862.2.3.el7.x86_64
         system: Linux
        version: CentOS Linux 7.6.1810 Core

2018.3.4 - Slack Output

test!help

salt APP [4:48 PM]
@rob.jones's job is submitted as salt jid 20190425204822315024

salt APP [4:48 PM]
Printing a list of available commands for: test
- help
- show_updates

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.

Thank you for updating this issue. It is no longer marked as stale.

Confirmed same issue on 3000.

Looks like the methods are now being invoked with args and kwargs parameters as of 2019.

Simple solution is to update the methods to pass them.

Old:
def test_help():

New
def test_help(args, *kwargs):

I'm running into this issue as well - just setup slack engine.

```Salt Version:
Salt: 3000

Dependency Versions:
cffi: 1.6.0
cherrypy: unknown
dateutil: Not Installed
docker-py: Not Installed
gitdb: 0.6.4
gitpython: 1.0.1
Jinja2: 2.7.2
libgit2: Not Installed
M2Crypto: 0.31.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.6.2
mysql-python: Not Installed
pycparser: 2.14
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.5 (default, Aug 7 2019, 00:51:29)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.1.4

System Versions:
dist: centos 7.7.1908 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-1062.4.1.el7.x86_64
system: Linux
version: CentOS Linux 7.7.1908 Core


Error output: 


fun:
    runner.state.orchestrate
jid:
    20200223003037632667
return:
    Exception occurred in runner state.orchestrate: Traceback (most recent call last):
      File "/usr/lib/python2.7/site-packages/salt/client/mixins.py", line 361, in low
        expected_extra_kws=CLIENT_INTERNAL_KEYWORDS
      File "/usr/lib/python2.7/site-packages/salt/utils/args.py", line 461, in format_call
        used_args_count
    SaltInvocationError: orchestrate takes at least 1 argument (0 given)
success:
    False
user:
    UNKNOWN

Collapse

```

Was this page helpful?
0 / 5 - 0 ratings