saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.09k stars 5.47k forks source link

fnmatch traceback #6521

Closed jcollie closed 11 years ago

jcollie commented 11 years ago

Getting the following traceback on 0.16.0 and 0.16.2. Not really sure where to begin to debug this.

Traceback (most recent call last): File "/usr/bin/salt-call", line 11, in salt_call() File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 76, in salt_call client.run() File "/usr/lib/python2.7/site-packages/salt/cli/init.py", line 265, in run caller.run() File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 129, in run ret = self.call() File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 70, in call ret['return'] = func(_args, *kwargs) File "/usr/lib/python2.7/site-packages/salt/modules/state.py", line 283, in sls ret = st.state.callhigh(high) File "/usr/lib/python2.7/site-packages/salt/state.py", line 1508, in call_high ret = self.call_chunks(chunks) File "/usr/lib/python2.7/site-packages/salt/state.py", line 1275, in call_chunks running = self.call_chunk(low, running, chunks) File "/usr/lib/python2.7/site-packages/salt/state.py", line 1445, in call_chunk running = self.call_chunk(chunk, running, chunks) File "/usr/lib/python2.7/site-packages/salt/state.py", line 1385, in call_chunk status = self.check_requisite(low, running, chunks, True) File "/usr/lib/python2.7/site-packages/salt/state.py", line 1325, in check_requisite if (fnmatch.fnmatch(chunk['name'], req_val) or File "/usr/lib64/python2.7/fnmatch.py", line 43, in fnmatch return fnmatchcase(name, pat) File "/usr/lib64/python2.7/fnmatch.py", line 75, in fnmatchcase res = translate(pat) File "/usr/lib64/python2.7/fnmatch.py", line 87, in translate i, n = 0, len(pat) TypeError: object of type 'NoneType' has no len()

jcollie commented 11 years ago
/etc/systemd/system/rancid@.service:
  file.managed:
    - source: salt://rancid/rancid@.service
    - user: root
    - group: root
    - mode: 0644
    - require:
      - pkg: rancid
      - user: rancid
      - file: /srv/rancid
      - file: /home/rancid/.cloginrc
      - file: 

Found the problem, had an entry that looked like the above, note the incomplete "file" requisite. While it's true that this is a user error, having a proper error message would be useful.

thatch45 commented 11 years ago

Yes, this should be an easy thing to catch :)

terminalmage commented 11 years ago

I've already tracked it down.

thatch45 commented 11 years ago

W00t!

terminalmage commented 11 years ago

I'm about to submit a pull for this. I was able to suppress this traceback by simply skipping the requisite chunks with a value of None. However, in the process I found that the state output looked a bit ugly, so I also changed the state output so that it's a bit more readable. @thatch45 what do you think of the following:

Old:

    State: - pkgrepo
    Name:      deb-src http://packages.dotdeb.org wheezy-php55 all
    Function:  managed
        Result:    False
        Comment:   The following requisites were not found:
                   require: OrderedDict([('file', None)])

        Changes:

New:

    State: - pkgrepo
    Name:      deb-src http://packages.dotdeb.org wheezy-php55 all
    Function:  managed
        Result:    False
        Comment:   The following requisites were not found:
                   require:
                       file: None

        Changes:
UtahDave commented 11 years ago

+1 from me. I think that looks much better.

jcollie commented 11 years ago

Thanks everyone for the quick turnaround!

terminalmage commented 11 years ago

No prob! Don't hesitate to let us know if you encounter any other problems.