-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Control the collection of lvm grains via config #63115
base: master
Are you sure you want to change the base?
Control the collection of lvm grains via config #63115
Conversation
dfac6d9
to
a4bb635
Compare
salt/grains/lvm.py
Outdated
|
||
.. code_block:: yaml | ||
|
||
enable_lvm_grains: False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we have another similar setting enable_fqdns_grains
, but I'm wondering if we should have a more global setting instead of creating a new config for each grain that might want to be disabled.
How about a config similar to disable_grains
which is a list of grains to disable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use a global config instead, that would make things a bit easier for the user. There already is the grains_blacklist
which is similar in concept but works on a different granularity. grains_blacklist
only filters the grains after they are computed, which does not help when grains computation is slow. But it allows, afaics, to filter out single grains out of a grain function that computes multiple grains. If every grain function only ever returned a single grain, we could just skip the computation for those functions based on the blacklist.
What do you think about the following:
- we add
disable_grains
- we add a "config translation layer" that automatically populates
disable_grains
from all existing "grains opt-out settings" - all grain modules that use these settings are changed to only check the single
disable_grains
list - we mark existing "grains opt-out settings" deprecated, telling users to use the
disable_grains
list instead
In an unrelated project, I just experienced how changing the configuration can go badly when old config keys are not accepted anymore and I'd keep 2. around for a long time to not break existing configs.
Depending on how we implement 2., enable_lvm_grains: False
could still work without explicitly allowing it. That it's of little interest to you, but could be useful in our downstream Salt package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on (we add a "config translation layer" that automatically populates disable_grains from all existing "grains opt-out settings")
I just want to be clear what your proposing on this one.
There other points sound solid to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I have two ways to do this in mind, either using a regex to extract the grains module from the existing "grains opt-out settings", or with a hard-coded list of known "opt-out settings". The overall approach is the same for both, if it's possible with a simple regex I'd prefer that approach since it's more open. Anyway, the idea is this:
At the end of apply_minion_config
in salt/config/__init__.py
, the existing config keys are checked (using the list or regex). For each match that's set to False
, the grain module name is added to disable_grains
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started implementing this and hit a bit of a blocker: some grains are currently disabled by default. I'm not sure how to handle this. If I add them to disabled_grains
per default (in DEFAULT_(MASTER|MINION)_OPTS
, the user can't take them out using a config file.
One way to solve this is to only add the default disabled_grains
in conf/master
and conf/minion
, but that's not a nice solution. Another way would be to also add an enabled_grains
(or similarly named) config, with the sole purpose of taking grains out of disabled_grains
.
How do you feel about this @Ch3LL ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please disregard my previous comment, I didn't see the forest for the trees, the user can simply provide disabled_grains
with the default(s) removed.
a4bb635
to
20368ac
Compare
I did a first implementation of |
@@ -351,9 +357,9 @@ def _gather_buffer_space(): | |||
"test": bool, | |||
# Tell the loader to attempt to import *.pyx cython files if cython is available | |||
"cython_enable": bool, | |||
# Whether or not to load grains for FQDNs | |||
# Whether or not to load grains for FQDNs (deprecated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the schema can have extra options, is it ok to remove the settings from it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its okay to put them on a deprecation path in favor of the new disabled_grains.
Can you make sure you add a comment:
# salt.utils.versions.warn_until(Potassium, "enabled_fqdns_grains is deprecated in favor of.......)
The only reason being is we grep the cod for warn_until and version name each time we work on removing deprecations.
Also add changelog files for each setting you are removing with the filename deprecated stating the details on what users can now use instead.
20368ac
to
3710c84
Compare
Looks like htere are some doc and lint test failures. When those are resolved i'll give this a full review. Thanks for implementing this. |
badc70b
to
4c4c083
Compare
I still have to do the requested changes for the deprecation. If possible, it would be great to have a review for the code changes. I'm a bit conflicted on having the grains do the "disabling" in |
ping @s0undt3ch any thoughts here? I think I tend to agree it would be nice if this logic was in the loader instead of having to add it to each |
Closing this due to inactivity. Anyone should feel free to re-open it if they want to see it through to the end in one release cycle. |
I would like to get this in, I think a multiple minutes grain collection time is pretty bad. I still don't know if my current approach is fine by you or if you'd rather do this in the loader. |
Great, and thanks for the reply. Please re-base and fix the conflicts so we can see if all tests pass. |
This option unifies the existing options to en-/disable grain computation. Instead of having one option per grains module/function, we have a single list now. The old options are automatically translated into `disabled_grains` entries.
4c4c083
to
1908eab
Compare
lvm grain collection can take a long time on systems with a lot of volumes and volume groups. On one server we measured ~3 minutes, which is way too long for grains. This change is backwards-compatible, leaving the lvm grain collection enabled by default. Users with a lot of lvm volumes/volume groups can disable these grains in the minion config by adding "lvm" to disabled_grains: disabled_grains: ... - lvm
1908eab
to
7afe6b8
Compare
What does this PR do?
Refactor options to control grain computation into a single
disabled_grains
list and makelvm
aware of it.lvm grain collection can take a long time on systems with a lot of volumes and volume groups. On one server we measured ~3 minutes, which is way too long for grains.
This change is backwards-compatible, leaving the lvm grain collection enabled by default.
What issues does this PR fix or reference?
Fixes: #63114
Previous Behavior
lvm grains are always loaded
New Behavior
lvm grains are not loaded when disabled in minion configuration
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
disabled_grains
Does this need a grains/lvm.conf specific test, or is this covered by the
__virtual__()
/ Salt loader tests?Commits signed with GPG?
Yes
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.