cmd.script does not work properly with bg=True
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue/Question
cmd.script in combination with source using salt:// and bg=True does not work as expected.
Setup
master and minion are the same. file_roots contains /srv/salt and there is a script.sh in this directory with the following content:
#!/bin/bash
sleep 300
minion process is run on console with salt-minion -t trace.
Steps to Reproduce Issue
first run the script in foreground (default):
salt MINION cmd.script source=salt://script.sh
minion logs:
[INFO ] Executing command '/tmp/__salt.tmp.NhvUDT.sh' in directory '/root'
and the sleep command is called:
$ ps -ef | grep sleep
root 32331 32330 0 13:31 ? 00:00:00 sleep 300
this works as designed. the problem arises after bg=True is added to kw-args.
salt MINION cmd.script source=salt://script.sh bg=True
this time minion logs the following error:
[DEBUG ] In saltenv 'base', looking at rel_path 'script.sh' to resolve 'salt://script.sh'
[DEBUG ] In saltenv 'base', ** considering ** path '/var/cache/salt/minion/files/base/script.sh' to resolve 'salt://script.sh'
[DEBUG ] LazyLoaded file.user_to_uid
[INFO ] Executing command '/tmp/__salt.tmp.7zNkaz.sh' in directory '/root'. Executing command in the background, no output will be logged.
[DEBUG ] Minion return retry timer set to 5 seconds (randomized)
[INFO ] Returning information for job: 20181029133404427449
/bin/bash: /tmp/__salt.tmp.7zNkaz.sh: No such file or directory
to me it looks like the script is removed (as part of the post-execution cleanup) prior to being passed to shell. this behaviour has been seen on AIX minions reporting to Linux masters.
Versions Report
Salt Version:
Salt: 2018.3.3
Dependency Versions:
cffi: 1.11.5
cherrypy: unknown
dateutil: 2.7.3
docker-py: Not Installed
gitdb: 2.0.5
gitpython: 2.1.11
ioflo: Not Installed
Jinja2: 2.10
libgit2: 0.27.4
libnacl: Not Installed
M2Crypto: 0.30.1
Mako: 1.0.7
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: 2.19
pycrypto: 3.6.6
pycryptodome: Not Installed
pygit2: 0.27.2
Python: 2.7.15 (default, Jun 27 2018, 13:05:28)
python-gnupg: Not Installed
PyYAML: 3.13
PyZMQ: 17.1.0
RAET: Not Installed
smmap: 2.0.5
timelib: Not Installed
Tornado: 5.1.1
ZMQ: 4.2.5
System Versions:
dist:
locale: UTF-8
machine: x86_64
release: 4.18.16-arch1-1-ARCH
system: Linux
version: Not Installed
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the cmd.script entry point and trace how source=salt://script.sh is staged and cleaned up when bg=True. Reproduce with the mentioned script.sh containing sleep 300, then verify that the background command can still execute the staged script after the initial command returns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, python
- Domain
- backend, cli, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100