saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

Regression bug in grains.list_present #27141

Closed racooper closed 6 years ago

racooper commented 9 years ago

Referencing https://gist.github.com/racooper/27cdee5293a861c80bd5

Apparently grains.list_present in 2015.5.0 (and earlier) would take a "list" value. In 2015.5.2, this is broken and is still broken in 2015.5.5 (all versions taken from EPEL).

jfindlay commented 9 years ago

@racooper, thanks for the report. This seems to be fixed on the 2015.8 branch.

cachedout commented 9 years ago

Regardless, this still needs to be fixed in the 2015.5 branch. We'll investigate.

cachedout commented 9 years ago

I can't replicate this at all. Here's the SLS I'm using:

zed:
  grains.list_present:
    - value:
      - foo
      - bar

I don't get any stacktraces in either 2015.5.2 or 2015.5.5. Could you try my testcase and see if it works for you? I'm curious about what's going on here.

racooper commented 9 years ago

your test SLS works for me, but testing again with my original sls still gives the "uhashable type: 'list'" error. This is under 2015.5.5 from EPEL, both server and minion.

roles:
  grains.list_present:
    - value:
      - webserver
      - configmaster
      - development

gives

          ID: roles
    Function: grains.list_present
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.6/site-packages/salt/state.py", line 1561, in call
                  **cdata['kwargs'])
                File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
                  self.gen.throw(type, value, traceback)
                File "/usr/lib/python2.6/site-packages/salt/utils/context.py", line 42, in func_globals_inject
                  yield
                File "/usr/lib/python2.6/site-packages/salt/state.py", line 1561, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.6/site-packages/salt/states/grains.py", line 107, in list_present
                  if set(value).issubset(set(__grains__.get(name))):
              TypeError: unhashable type: 'list'
     Started: 15:03:59.403141
    Duration: 2.497 ms
     Changes:   
cachedout commented 9 years ago

I still can't replicate this:

 % sudo salt silver state.sls issue_27141                                                                                                                      (git)-[umask_note] 
silver:
----------
          ID: roles
    Function: grains.list_present
      Result: True
     Comment: Append value ['webserver', 'configmaster', 'development'] to grain roles
     Started: 16:01:51.816640
    Duration: 5287.49 ms
     Changes:   
              ----------
              new:
                  ----------
                  roles:
                      - item1
                      - item2
                      - item3
                      - osarch
                      - osrelease
                      - foo
                      - bar
                      - webserver
                      - configmaster
                      - development

Summary
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
 % salt --versions-report                                                                                                                                       (git)-[v2015.5.5] 
           Salt: 2015.5.5
         Python: 2.7.10 (default, Sep  7 2015, 13:51:49)
         Jinja2: 2.8
       M2Crypto: 0.21.1
 msgpack-python: 0.4.6
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
        libnacl: 1.4.0
         PyYAML: 3.11
          ioflo: 1.4.3
          PyZMQ: 15.0.0
           RAET: 0.6.5
            ZMQ: 4.1.3
           Mako: 1.0.3
        Tornado: 4.3
        timelib: 0.2.4
       dateutil: 2.4.2

Is there something else in your minion's grains that might be causing this? I'm at a bit of a loss here.

frogunder commented 8 years ago

@racooper - Have you figured this out, or is this still an issue for you?

frogunder commented 8 years ago

@racooper - I recently tested this again against version 2015.5.5. I don't get your error, it is working correctly.

If you have time can you try again too see if you still get the error message?

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.