Check dmidecoder executable on each "smbios" call to avoid race condition#48781
Closed
meaksh wants to merge 3 commits into
Closed
Check dmidecoder executable on each "smbios" call to avoid race condition#48781meaksh wants to merge 3 commits into
meaksh wants to merge 3 commits into
Conversation
Contributor
|
@meaksh Can you fix up the lint failures listed here? https://jenkinsci.saltstack.com/job/pr-lint/job/PR-48781/1/warnings52Result/package.2029219534/ |
Contributor
Author
|
@rallytime - pylint issues fixed 👍 |
isbm
suggested changes
Jul 27, 2018
Contributor
isbm
left a comment
There was a problem hiding this comment.
I will follow-up on this PR differently.
|
|
||
| def _refresh_dmidecoder(): | ||
| global DMIDECODER | ||
| DMIDECODER = salt.utils.path.which_bin(['dmidecode', 'smbios']) |
Contributor
There was a problem hiding this comment.
Why there is a need of this global variable at all? And this function is also not needed. I would discard this PR entirely and just refactor it the way that which_bin is just called.
Contributor
|
🛑 |
Contributor
|
Closed in favor of #48814 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR fixes a race condition happening during core grains generation in case
dmidecodeorsmbiosare installed/removed duringsalt-minionexecution.As described on #35505,
smbios.DMIDECODERis fixed to thedmidecodeorsmbiosexecutables, and this is happening only once while the module is loaded. Then there are some calls tosmbios.getperformed while calculating the "core" grains which produces a race condition in case the results ofsalt.utils.path.which_bin(['dmidecode', 'smbios'])changes during execution time.What issues does this PR fix or reference?
Hopefully fixes #35505
Previous Behavior
The situation appears in case neither
dmidecodenorsmbiosare installed at the time ofsalt-minionis started, thereforesmbios.DMIDECODERis set toNone. Then, at some point, eitherdmidecodeorsmbiosare installed on the minion and eventually the grains will be recalculated.At this particular moment, when the "core" grains are being recalculated, https://github.com/saltstack/salt/blob/2018.3/salt/grains/core.py#L2310 is checking again if executables are now available, and if so, it would produce a call to
smbios.getwhich will crash sincesmbios.DMIDECODERis set toNone:New Behavior
Now
smbios.DMIDECODERis refreshed on eachsmbiosmodule call to prevent the race condition with the "core" grains. Besides of that, this PR introduces also a comprehensive error message in case of crashing:Tests written?
No
Commits signed with GPG?
Yes