salt icon indicating copy to clipboard operation
salt copied to clipboard

Thorium runner.cmd is not working

Open kiemlicz opened this issue 7 years ago • 4 comments

Description of Issue/Question

Thorium's runner.cmd is not building arguments properly (I guess).

Setup

Create something like this in some example sls under thorium_roots:

some_orchestrate:
  runner.cmd:
    - func: state.orchestrate
    - arg:
        - some.sls.file
    - kwargs:
        saltenv: server

For convenience setup rawfile_json

Steps to Reproduce Issue

Send some events to trigger thorium
saltenv will not be passed to the state.orchestrate The event dump:

{"tag": "salt/run/20181124220603287357/new", "data": {"fun": "runner.state.orchestrate", "fun_args": ["some.sls.file", {"orchestration_jid": "20181124220603287357"}]

Trying to:

some_orchestrate:
  runner.cmd:
    - func: state.orchestrate
    - arg:
        - some.sls.file
        - saltenv: server

Brings me closer to solution but still doesn't work

{"tag": "salt/run/20181124221236510322/new", "data": {"fun": "runner.state.orchestrate", "fun_args": ["some.sls.file", {"saltenv": "server"}, {"orchestration_jid": "20181124221236510322"}], "jid": "20181124221236510322", "user": "root", "_stamp": "2018-11-24T21:12:37.190855"}}

Mind separated {'orchestration_jid': ...}

How do I get this working (workaround)?
I'm guessing the problem is here (thorium/runner.py):

    local_opts = {}
    local_opts.update(__opts__)
    local_opts['async'] = True  # ensure this will be run asynchronous
    local_opts.update({
        'fun': func,
        'arg': arg,
        'kwarg': kwargs
    })
    runner = salt.runner.Runner(local_opts)
    runner.run()

Could you give me hints or code reference where these options are properly handled so that I'll fix it myself?

Versions Report

Salt Version:
           Salt: 2018.3.3

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.5.3
      docker-py: 3.5.1
          gitdb: 2.0.0
      gitpython: 2.1.1
          ioflo: Not Installed
         Jinja2: 2.9.4
        libgit2: 0.24.5
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.24.2
         Python: 2.7.13 (default, Sep 26 2018, 18:42:22)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.1
        timelib: Not Installed
        Tornado: 4.4.3
            ZMQ: 4.2.1

System Versions:
           dist: debian 9.6
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-8-amd64
         system: Linux
        version: debian 9.6

kiemlicz avatar Nov 24 '18 21:11 kiemlicz

just taking a quick glance at the code i think you are pointing in the right direction of the issue. Because when it hits runner.run() this is what kwargs becomes: https://github.com/saltstack/salt/blob/v2018.3.3/salt/runner.py#L199-L201

It never references self.opts['kwargs'] and when it tries to parse the kwargs and args with the call salt.minion.load_args_and_kwargs it tires parsing self.opts['arg']. i've not been in this code a ton but i'm guessing that kwargs will need to be added to the args in thorium/runner.py.

but someone from @saltstack/team-core can correct me if i'm wrong about that analysis

Ch3LL avatar Nov 26 '18 16:11 Ch3LL

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 Jan 09 '20 12:01 stale[bot]

gladly reopen the issue.

kiemlicz avatar Jan 09 '20 13:01 kiemlicz

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

stale[bot] avatar Jan 09 '20 13:01 stale[bot]