Content-Length: 352463 | pFad | http://github.com/saltstack/salt/pull/68184

32 disks grain: fix exception on Windows by xsmile · Pull Request #68184 · saltstack/salt · GitHub
Skip to content

disks grain: fix exception on Windows #68184

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

Merged
merged 3 commits into from
Jul 20, 2025
Merged

disks grain: fix exception on Windows #68184

merged 3 commits into from
Jul 20, 2025

Conversation

xsmile
Copy link

@xsmile xsmile commented Jul 14, 2025

What does this PR do?

Running Get-PhysicalDisk does not return a MediaType property on Windows Server 2012. This causes an exception when loading the disks grain.

[CRITICAL] Failed to load grains defined in grain file disks.disks in function <LoadedFunc name='disks.disks'>, error:
Traceback (most recent call last):
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\loader\__init__.py", line 1188, in grains
    ret = funcs[key](**kwargs)
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\loader\lazy.py", line 159, in __call__
    ret = self.loader.run(run_func, *args, **kwargs)
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\loader\lazy.py", line 1245, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\loader\lazy.py", line 1260, in _run_as
    ret = _func_or_method(*args, **kwargs)
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\grains\disks.py", line 34, in disks
    return _windows_disks()
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\grains\disks.py", line 173, in _windows_disks
    if drive["MediaType"].lower() not in ["hdd", "ssd", "scm", "unspecified"]:
AttributeError: 'NoneType' object has no attribute 'lower'

Previous Behavior

Loading the disks grain fails and causes an AttributeError.

New Behavior

Loading the disks grain fails silently.

Merge requirements satisfied?

Commits signed with GPG?

No

@xsmile xsmile requested a review from a team as a code owner July 14, 2025 11:50
Copy link
Contributor

@twangboy twangboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write a test for this

@dwoz dwoz merged commit 930470f into saltstack:3006.x Jul 20, 2025
1321 of 1323 checks passed
Copy link

welcome bot commented Jul 20, 2025

Congratulations on your first PR being merged! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test:full Run the full test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/saltstack/salt/pull/68184

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy