cmd.run state doesn't print stdout's last character when stateful=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
When executing the state cmd.run on a minion with stateful set to True and the command returns key/value pairs (not JSON), then the last character printed in the Changes: section is omitted.
Setup
Ran on debian10 with 2019.2.3+ds-1 salt package, but I've verified it in various previous salt versions (eg. 2018.3.1 and 2018.3.2) on various systems (eg. debian9 and SmartOS 18.4, 19.4, 17.2).
Steps to Reproduce Issue
Create the following sls file in your file-roots (let's call it testit.sls):
test output1:
cmd.run:
- name: echo changed=True lala=lolo lili=lele
test output2:
cmd.run:
- name: echo changed=True lala=lolo lili=lele
- stateful: True
and then run it. The output you'll get will be something like:
# salt 'testmachine' state.apply testit
testmachine:
----------
ID: test output1
Function: cmd.run
Name: echo changed=True lala=lolo lili=lele
Result: True
Comment: Command "echo changed=True lala=lolo lili=lele" run
Started: 13:37:29.594337
Duration: 83.475 ms
Changes:
----------
pid:
20544
retcode:
0
stderr:
stdout:
changed=True lala=lolo lili=lele
----------
ID: test output2
Function: cmd.run
Name: echo changed=True lala=lolo lili=lele
Result: True
Comment:
Started: 13:37:29.678552
Duration: 77.335 ms
Changes:
----------
changed:
True
lala:
lolo
lili:
lele
pid:
20545
retcode:
0
stderr:
stdout:
changed=True lala=lolo lili=lel
Summary for testmachine
------------
Succeeded: 2 (changed=2)
Failed: 0
------------
Total states run: 2
Total run time: 160.810 ms
where one can see that the final e is missing from the output2 (where stateful is set to True).
Versions Report
Salt: 2019.2.3
Dependency Versions:
cffi: Not Installed
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: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.7.3 (default, Apr 3 2019, 05:39:12)
python-gnupg: Not Installed
PyYAML: 3.13
PyZMQ: 17.1.2
RAET: Not Installed
smmap: 2.0.5
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.1
System Versions:
dist: debian 10.2
locale: UTF-8
machine: x86_64
release: 4.19.0-6-cloud-amd64
system: Linux
version: debian 10.2
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
Reproduce the issue with the provided testit.sls file by running salt 'testmachine' state.apply testit on a stateful cmd.run. Trace the cmd.run stateful output handling, then verify that the final stdout character is preserved and add a regression test covering non-JSON key/value output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100