Skip to content

cmd.script does not work properly with bg=True #50273

Description

@jose1711

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

Activity

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

    bugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions