[state.dockerio] docker.run TypeError: run() argument after ** must be a mapping, not str
Getting the following error running state.highstate
----------
ID: /reload.sh
Function: docker.run
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 1371, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/dist-packages/salt/states/dockerio.py", line 548, in run
return drun(**cmd_kwargs)
TypeError: run() argument after ** must be a mapping, not str
Changes:
I am trying to run a command inside a container the following way:
/reload.sh:
docker.run:
- cid: f56154a814f1ecd6961b6314c589a5765e15ed8e85567be399982d1b3efa324c
- watch:
- file: /config.cfg
The documentation http://docs.saltstack.com/en/latest/ref/states/all/salt.states.dockerio.html suggest doing it the following way:
/finish-install.sh:
docker.run:
- container: mysuperdocker
- unless: grep -q something /var/log/foo
- docker_unless: grep -q done /install_log
Whereas the syntax at http://docs.saltstack.com/en/latest/ref/states/all/salt.states.dockerio.html#salt.states.dockerio.run only mentions a cid, not a container argument.
Thanks for the report! We'll look into it.
This module/state is still under active development, so it would be very helpful if you could post what version the master and minion are both running. To be honest, this is pretty basic information that should be included with any bug report.
Also, it looks like this function has been refactored since 2014.1.1 was released, so this is likely fixed already. Here is the 2014.1.1 version of that function, while here is the current state of the function.
I'm going to mark this as "Fixed Pending Verification", until such time as it can be tested against newer code.
Hi, thank you very much for your reply.
My master is running 2014.1.1 on ubuntu 12.04 while the minion is running 2014.1.0 on ubuntu 13.10. Unfortunately the 2014.1.1 package is only available for ubuntu 12.04 at the moment, so I will figure out a way, test it with the newest version and get back to you.
@MarkusMuellerAU were you able to test this on a newer release?
Sorry for the delay and thank you for following up. I installed the following versions on Ubuntu 12.04.3, salt-master and salt-minion versions report:
Salt: 2014.1.0-6599-g283495a
Python: 2.7.3 (default, Apr 10 2013, 06:20:15)
Jinja2: 2.6
M2Crypto: 0.21.1
msgpack-python: 0.1.10
msgpack-pure: Not Installed
pycrypto: 2.4.1
PyYAML: 3.10
PyZMQ: 13.0.0
ZMQ: 3.2.2
Hope this is the latest development version?
Unfortunately I am getting a different error now:
ubuntu:
----------
ID: /run.sh
Function: docker.run
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/home/mamu/salt/salt/salt/state.py", line 1430, in call
**cdata['kwargs'])
File "/home/mamu/salt/salt/salt/states/dockerio.py", line 530, in run
result = drun_all(cid, name)
File "/home/mamu/salt/salt/salt/modules/dockerio.py", line 1908, in run_all
status, container, 'cmd.run_all', cmd)
File "/home/mamu/salt/salt/salt/modules/dockerio.py", line 1831, in _run_wrapper
' to attach to the container'.format(driver))
NotImplementedError: Unknown docker ExecutionDriver u'native-0.2'. Or didn't found command to attach to the container
Started: 22:15:06.153145
Duration: 84 ms
Changes:
Other docker states like docker.installed are working fine:
ID: mysuperdocker-container
Function: docker.installed
Name: mysuperdocker
Result: True
Comment: Container 0b6aa86c4cb69aa396ca51f8597f94ede6ef5d8d3508ad8bee96a0283e48decf created
Started: 22:15:06.238150
Duration: 122 ms
Changes: Invalid Changes data: Container 0b6aa86c4cb69aa396ca51f8597f94ede6ef5d8d3508ad8bee96a0283e48decf created
Please let me know if you need any additional output or if I might have missed something?
@rallytime not sure if you have you seen my reply?
@MarkusMuellerAU - thanks for the ping! I did see your comment, but I got distracted and didn't look into it until now.
I think the problem revolves around installing nsenter. Since you're using Ubuntu, can you follow the directions in the "Use nsenter" section in the following link to compile and install nsenter and run your state on the develop branch again?
http://jpetazzo.github.io/2014/03/23/lxc-attach-nsinit-nsenter-docker-0-9/
@MarkusMuellerAU is this still an issue for you?
@rallytime - Thank you for the hint to install nsenter, this solved the issue.
Great! I am going to close this one out, then. If this problem pops up again for anyone, leave a comment and we'll re-open!
@rallytime problem is back one with: NotImplementedError: Unknown docker ExecutionDriver u'native-0.2'
salt 2014.7.2 docker-py 1.0.0 docker 1.4.1
Currently run should have been implemented using docker exec
Plus webpage documentation is misleading saying that one should go for:
/finish-install.sh:
docker.run:
- container: mysuperdocker
while is should have been (cid)
/finish-install.sh:
docker.run:
- cid: mysuperdocker
PS: Technically issue should have been closed when user found workaround and salt docker state is still broken.
Thanks for letting us know. I've re-opened the issue. Thanks!
+1 I'm also running into the NotImplementedError with 2014.7.4. In case anybody else happens across this issue, a fairly straightforward alternative is something like:
mypostsetupcmd:
require:
- docker: some-docker-running-state
cmd.wait:
- name: >
docker exec {{ container_name }}
your commands here…
- watch:
- docker: some-docker-installed-state
Looking at dockerio.py, the only way that an ExecutionDriver of "native-0.2" would not be supported is if nsenter is not installed on the minion. nsenter is usually included with the "util-linux" package. Can you run salt <minion_id> cmd.run_all 'which nsenter' (replacing <minion_id> with the minion ID of the affected host)? If there is no text in the stdout field in the return data, and the retcode is not 0, you don't have nsenter installed and that is why the failure is happening. In that case, installing util-linux (or whatever provides nsenter on your platform) should be all you need to do to get this working.
For what it's worth, in my full rewrite of Salt's docker support (see here), docker-exec is used for Docker 1.3 and later.
I've submitted https://github.com/saltstack/salt/pull/22898 to improve the error message when nsenter is not available.
I have cleaned up the example in the documentation to use the correct cid kwarg (instead of container) for the docker.run state example.
With the helpful nsenter check from @terminalmage in his pull request, as well as with this documentation clean up, I think this one is now resolved again. Thoughts from @munhitsu or @tkent-xetus?
@terminalmage
Thank you very much for that quick reply! I didn't even think I could missing be a dependency, sorry for not checking first. Our OS (Ubuntu 14.04) doesn't happen to include nsenter with util-linux, but I went ahead and installed it manually.
@rallytime
Thanks for patching up the docs, and sorry for missing your earlier comment around nsenter! I can confirm that docker.run works in my case. Here's the relevant parts of our setup if anybody ever needs to reference it:
- ubuntu 14.04 (w/nsenter manually installed)
- salt 2014.7.4
- docker 1.5.0
However, I still can't use it without still throwing in a little docker exec statement due to #17088
@tkent-xetus Awesome! Thanks for verifying everything. Since this particular issue has had all of it's pieces patched up and there is already another bug open for the docker exec part, can we close this issue up again?
@rallytime I would say so!