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

Prevent crash by testing for 'manufacturer' in osdata on OpenBSD #51159

Merged
merged 1 commit into from Jan 14, 2019

Conversation

Projects
None yet
2 participants
@rkrieger
Copy link

commented Jan 13, 2019

What does this PR do?

Two things, on OpenBSD systems:

  1. check for existence of manufacturer key in osdata
  2. recognize SmartOS KVM in _virtual()

What issues does this PR fix or reference?

Issue #51067

Previous Behavior

On my Raspberry Pi 3B:

# salt-call --local grains.items | egrep -A1 'kernel|productname|virtual|manufacturer'
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
KeyError: u'manufacturer'
Traceback (most recent call last):
  File "/usr/local/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/local/lib/python2.7/site-packages/salt/scripts.py", line 400, in salt_call
    client.run()
  File "/usr/local/lib/python2.7/site-packages/salt/cli/call.py", line 47, in run
    caller = salt.cli.caller.Caller.factory(self.config)
  File "/usr/local/lib/python2.7/site-packages/salt/cli/caller.py", line 79, in factory
    return ZeroMQCaller(opts, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/salt/cli/caller.py", line 291, in __init__
    super(ZeroMQCaller, self).__init__(opts)
  File "/usr/local/lib/python2.7/site-packages/salt/cli/caller.py", line 102, in __init__
    self.minion = salt.minion.SMinion(opts)
  File "/usr/local/lib/python2.7/site-packages/salt/minion.py", line 784, in __init__
    opts['grains'] = salt.loader.grains(opts)
  File "/usr/local/lib/python2.7/site-packages/salt/loader.py", line 734, in grains
    ret = funcs[key]()
  File "/usr/local/lib/python2.7/site-packages/salt/grains/core.py", line 1792, in os_data
    grains.update(_virtual(grains))
  File "/usr/local/lib/python2.7/site-packages/salt/grains/core.py", line 925, in _virtual
    if osdata['manufacturer'] in ['QEMU', 'Red Hat']:
KeyError: u'manufacturer'
Traceback (most recent call last):
  File "/usr/local/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/local/lib/python2.7/site-packages/salt/scripts.py", line 400, in salt_call
    client.run()
  File "/usr/local/lib/python2.7/site-packages/salt/cli/call.py", line 47, in run
    caller = salt.cli.caller.Caller.factory(self.config)
  File "/usr/local/lib/python2.7/site-packages/salt/cli/caller.py", line 79, in factory
    return ZeroMQCaller(opts, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/salt/cli/caller.py", line 291, in __init__
    super(ZeroMQCaller, self).__init__(opts)
  File "/usr/local/lib/python2.7/site-packages/salt/cli/caller.py", line 102, in __init__
    self.minion = salt.minion.SMinion(opts)
  File "/usr/local/lib/python2.7/site-packages/salt/minion.py", line 784, in __init__
    opts['grains'] = salt.loader.grains(opts)
  File "/usr/local/lib/python2.7/site-packages/salt/loader.py", line 734, in grains
    ret = funcs[key]()
  File "/usr/local/lib/python2.7/site-packages/salt/grains/core.py", line 1792, in os_data
    grains.update(_virtual(grains))
  File "/usr/local/lib/python2.7/site-packages/salt/grains/core.py", line 925, in _virtual
    if osdata['manufacturer'] in ['QEMU', 'Red Hat']:

On my SmartOS HVM:

# salt-call --local grains.items | egrep -A1 'kernel|productname|virtual|manufacturer'
    kernel:
        OpenBSD
    kernelrelease:
        6.4
    kernelversion:
        GENERIC#3
    manufacturer:
        Joyent
    productname:
        SmartDC HVM
    virtual:
        physical

New Behavior

On my Raspberry Pi 3B:

# salt-call --local grains.items | egrep -A1 'kernel|productname|virtual|manufacturer'
    kernel:
        OpenBSD
    kernelrelease:
        6.4
    kernelversion:
        GENERIC.MP#3
    productname:
        Raspberry Pi 3 Model B Rev 1.2
    virtual:
        physical

On my SmartOS HVM:

# salt-call --local grains.items | egrep -A1 'kernel|productname|virtual|manufacturer'
    kernel:
        OpenBSD
    kernelrelease:
        6.4
    kernelversion:
        GENERIC#3
    manufacturer:
        Joyent
    productname:
        SmartDC HVM
    virtual:
        kvm

Tests written?

No

Commits signed with GPG?

No

@garethgreenaway garethgreenaway merged commit 1424734 into saltstack:2018.3 Jan 14, 2019

8 of 10 checks passed

continuous-integration/jenkins/pr-merge This commit cannot be built
Details
jenkins/pr/py3-windows-2016 The py3-windows-2016 job has failed
Details
WIP Ready for review
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint Python lint test has passed
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py2-windows-2016 The py2-windows-2016 job has passed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.