Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grains.has_key() always returns false in 2016.3.0 #33614

Closed
knuta opened this issue May 29, 2016 · 4 comments
Closed

grains.has_key() always returns false in 2016.3.0 #33614

knuta opened this issue May 29, 2016 · 4 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt fixed-pls-verify fix is linked, bug author to confirm fix severity-critical top severity, seen by most users, serious issues ZRELEASED - Boron
Milestone

Comments

@knuta
Copy link
Contributor

knuta commented May 29, 2016

Description of Issue/Question

grains.has_key() always returns false in 2016.3.0

Setup

Our config has used constructs like {% if grains.has_key('os_family') and grains['os_family'] == 'Debian' %} for grains which are not present on all architectures. On 2016.3.0, this stopped working, but "grains.os_family is defined" still works.

Example SLS snippet for testing:

/tmp/graintest:
  file.managed:
    - contents: |
{% if grains.has_key('os_family') %}
        grains.has_key works
{% else %}
        grains.has_key doesn't work
{% endif %}
{% if grains.os_family is defined %}
        "is defined" works
{% else %}
        "is defined" doesn't work
{% endif %}

The resulting file (with empty lines removed) is:

grains.has_key doesn't work
"is defined" works

Steps to Reproduce Issue

Just run state.highstate with the SLS snipet above and look in /tmp/graintest.

Versions Report

skrotnisse:~# salt-call --versions-report
Salt Version:
Salt: 2016.3.0

Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 1.5
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.6
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.21.1
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.3.0
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.3 (default, Mar 14 2014, 11:57:14)
python-gnupg: Not Installed
PyYAML: 3.10
PyZMQ: 13.1.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 3.2.3

System Versions:
dist: debian 7.10
machine: i686
release: 3.2.0-4-686-pae
system: Linux
version: debian 7.10

My salt master is currently running 2015.5.3, but I do not think that is relevant in this case, since the jinja is rendered on the client side as far as I can tell.

@wwentland
Copy link
Contributor

It should be pointed out that your master should always be upgraded first and that the version you have installed has an unfixed CVE (cf. https://security-tracker.debian.org/tracker/CVE-2016-3176).

I would recommend to upgrade the master as soon as possible. Not sure if this is actually related to the problem at hand.

@knuta
Copy link
Contributor Author

knuta commented May 30, 2016

I have since upgraded my master to 2016.3 (I was halfway through a sitewide upgrade when I found the bug), and the behavior is the same.

@wwentland
Copy link
Contributor

wwentland commented May 30, 2016

Thank you for checking!

@meggiebot meggiebot added severity-critical top severity, seen by most users, serious issues ZRELEASED - Boron labels May 31, 2016
@meggiebot meggiebot added this to the C 9 milestone May 31, 2016
cachedout pushed a commit to cachedout/salt that referenced this issue May 31, 2016
We were missing the proper grains dictionary in the renderer context. This restores it.

Closes saltstack#33614
@cachedout cachedout added the fixed-pls-verify fix is linked, bug author to confirm fix label May 31, 2016
@rallytime rallytime added Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt labels May 31, 2016
@cachedout
Copy link
Contributor

This is all fixed up by #33651

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt fixed-pls-verify fix is linked, bug author to confirm fix severity-critical top severity, seen by most users, serious issues ZRELEASED - Boron
Projects
None yet
Development

No branches or pull requests

5 participants