When running ini.options_present on MacOS, if the keys are different or don't exist, the command will work as expected. However, when running again with no changes needed it crashes with this trace:
ID: Test
Function: ini.options_present
Name: /Users/--/test.ini
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/local/Cellar/saltstack/2017.7.1/libexec/lib/python2.7/site-packages/salt/state.py", line 1837, in call
**cdata['kwargs'])
File "/usr/local/Cellar/saltstack/2017.7.1/libexec/lib/python2.7/site-packages/salt/loader.py", line 1794, in wrapper
return f(*args, **kwargs)
File "/usr/local/Cellar/saltstack/2017.7.1/libexec/lib/python2.7/site-packages/salt/states/ini_manage.py", line 90, in options_present
__salt__['ini.set_option'](name, {section_name: section_body}, separator)[section_name])
KeyError: 'test'
Started: 16:15:13.835260
Duration: 0.997 ms
Changes:
Test:
ini.options_present:
- name: /Users/--/test.ini
- sections:
test:
'a': 'aa'
$ touch ~/test.ini
Then using salt-call on the sls above, first time it is successful. Second time the crash as above.
Salt Version:
Salt: 2017.7.1
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.9.6
libgit2: Not Installed
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: Not Installed
Python: 2.7.10 (default, Feb 7 2017, 00:08:15)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 16.0.2
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.1
ZMQ: 4.2.2
System Versions:
dist:
locale: UTF-8
machine: x86_64
release: 16.7.0
system: Darwin
version: 10.12.6 x86_64
@ikoruk Thanks for the report. I haven't been able to reproduce this issue so I suspect it's only happening on MacOS. Have you managed to reproduce it anywhere else?
I can reproduce using Ubuntu Xenial (using 2017.7.1 installed through pip).
Doing as described I get the following stacktrace when no changes need to be applied to the file:
[ERROR ] An exception occurred in this state: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/salt/state.py", line 1837, in call
**cdata['kwargs'])
File "/usr/local/lib/python2.7/dist-packages/salt/loader.py", line 1794, in wrapper
return f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/salt/states/ini_manage.py", line 90, in options_present
__salt__['ini.set_option'](name, {section_name: section_body}, separator)[section_name])
KeyError: 'test'
local:
----------
ID: Test
Function: ini.options_present
Name: /home/user/test.ini
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/salt/state.py", line 1837, in call
**cdata['kwargs'])
File "/usr/local/lib/python2.7/dist-packages/salt/loader.py", line 1794, in wrapper
return f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/salt/states/ini_manage.py", line 90, in options_present
__salt__['ini.set_option'](name, {section_name: section_body}, separator)[section_name])
KeyError: 'test'
Started: 09:20:17.596333
Duration: 1.768 ms
Changes:
Summary for local
------------
Succeeded: 0
Failed: 1
------------
Total states run: 1
Total run time: 1.768 ms
Here you can see my versions report:
Salt Version:
Salt: 2017.7.1
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: 1.10.6
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.8
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 16.0.2
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.1
ZMQ: 4.1.6
System Versions:
dist: Ubuntu 16.04 xenial
locale: UTF-8
machine: x86_64
release: 4.4.0-93-generic
system: Linux
version: Ubuntu 16.04 xenial
I also managed to reproduce using docker with debian and alpine. Here are the 2 Dockerfiles that I used:
FROM alpine:latest
RUN apk update
RUN apk add --no-cache python
RUN python -m ensurepip
RUN apk add g++ gcc python-dev
RUN pip install salt
FROM debian:latest
RUN apt update
RUN apt install python python-pip -y
RUN pip install salt
i get very same error on ubuntu 16.04
ini.options_present fails when there is no changes
```Salt Version:
Salt: 2017.7.1
Dependency Versions:
cffi: 1.5.2
cherrypy: 3.2.3
dateutil: 2.4.2
docker-py: Not Installed
gitdb: 0.6.4
gitpython: 1.0.1
ioflo: Not Installed
Jinja2: 2.8
libgit2: 0.24.0
libnacl: Not Installed
M2Crypto: Not Installed
Mako: 1.0.3
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: 2.14
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: 0.24.0
Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.2.0
RAET: Not Installed
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: Ubuntu 16.04 xenial
locale: UTF-8
machine: x86_64
release: 4.4.0-1031-aws
system: Linux
version: Ubuntu 16.04 xenial
```
also looks like problem has been fixed: https://github.com/saltstack/salt/commit/9478729120270b2b2b2b2f41a4517fe0de7b11bd
Thanks for tracking that down @gulbinas. That change was back-ported to the 2017.7 branch after the fix went into develop. The fix will be included in the upcoming 2017.7.2 release.
@ikoruk Do you think this issue can be closed?
Good for me.
Most helpful comment
I can reproduce using Ubuntu Xenial (using 2017.7.1 installed through pip).
Doing as described I get the following stacktrace when no changes need to be applied to the file:
Here you can see my versions report:
I also managed to reproduce using docker with debian and alpine. Here are the 2 Dockerfiles that I used: