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

Fix getting total available memory without psutil installed #34844

Merged
merged 2 commits into from
Jul 21, 2016
Merged

Fix getting total available memory without psutil installed #34844

merged 2 commits into from
Jul 21, 2016

Conversation

vutny
Copy link
Contributor

@vutny vutny commented Jul 21, 2016

What does this PR do?

Fixes Salt crash on Linux without psutil Python module installed.

What issues does this PR fix or reference?

The issue was introduced by this PR: #34683

Previous Behavior

[root@salt /]# salt --version
Traceback (most recent call last):
  File "/usr/bin/salt", line 10, in <module>
    salt_main()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 462, in salt_main
    import salt.cli.salt
  File "/usr/lib/python2.7/site-packages/salt/cli/salt.py", line 9, in <module>
    import salt.utils.job
  File "/usr/lib/python2.7/site-packages/salt/utils/job.py", line 8, in <module>
    import salt.minion
  File "/usr/lib/python2.7/site-packages/salt/minion.py", line 78, in <module>
    import salt.client
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 29, in <module>
    import salt.config
  File "/usr/lib/python2.7/site-packages/salt/config/__init__.py", line 92, in <module>
    _DFLT_IPC_WBUFFER = _gather_buffer_space() * .5
  File "/usr/lib/python2.7/site-packages/salt/config/__init__.py", line 84, in _gather_buffer_space
    os_data = salt.grains.core.os_data()
  File "/usr/lib/python2.7/site-packages/salt/grains/core.py", line 1386, in os_data
    grains.update(_linux_gpu_data())
  File "/usr/lib/python2.7/site-packages/salt/grains/core.py", line 154, in _linux_gpu_data
    if __opts__.get('enable_lspci', True) is False:
NameError: global name '__opts__' is not defined

__opts__ dictionary is not available because you're loading configuration right now, "chicken and the egg" problem appears.

But just for getting mem_totalGrain value you don't need full blown OS data, only to know what's the OS kernel (see _memdata function). This should be safe on all supported platforms.

New Behavior

Salt works.

Tests written?

No

@cachedout cachedout merged commit 650674d into saltstack:2016.3 Jul 21, 2016
@vutny vutny deleted the fix-grains-load-in-config-init branch July 21, 2016 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants