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

salt.modules.disk.percent() throws KeyError when partition doesn't exist #27238

Merged
merged 1 commit into from Sep 18, 2015

Conversation

arnisoph
Copy link
Contributor

Thanks to @iigorr for reporting the issue!

Before:

# salt-call -l info disk.percent foo
[INFO    ] Executing command 'df -P' in directory '/root'
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
KeyError: 'foo'
Traceback (most recent call last):
  File "/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 331, in salt_call
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 51, in run
    caller.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 133, in run
    ret = self.call()
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 196, in call
    ret['return'] = func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/modules/disk.py", line 203, in percent
    return ret[args]
KeyError: 'foo'
Traceback (most recent call last):
  File "/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 331, in salt_call
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 51, in run
    caller.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 133, in run
    ret = self.call()
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 196, in call
    ret['return'] = func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/modules/disk.py", line 203, in percent
    return ret[args]
KeyError: 'foo'

After:

# salt-call -l info disk.percent foo
[INFO    ] Executing command 'df -P' in directory '/root'
[ERROR   ] Problem parsing disk usage information: Partition 'foo' does not exist!
local:
    ----------

#27239 should be a working test for this case.

arnisoph added a commit to arnisoph/salt that referenced this pull request Sep 18, 2015
basepi added a commit that referenced this pull request Sep 18, 2015
salt.modules.disk.percent() throws KeyError when partition doesn't exist
@basepi basepi merged commit 652b299 into saltstack:2015.8 Sep 18, 2015
@arnisoph arnisoph deleted the fix_disk_percent_keyerror branch September 18, 2015 19:44
@jfindlay jfindlay added Minor Change Platform Relates to OS, containers, platform-based utilities like FS, system based apps Tests-Passed labels Sep 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Relates to OS, containers, platform-based utilities like FS, system based apps Tests-Passed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants