Skip to content

Control the collection of lvm grains via config - #63115

Open
agraul wants to merge 3 commits into
saltstack:masterfrom
agraul:control-lvm-grains-collection-config
Open

Control the collection of lvm grains via config#63115
agraul wants to merge 3 commits into
saltstack:masterfrom
agraul:control-lvm-grains-collection-config

Conversation

@agraul

@agraul agraul commented Nov 25, 2022

Copy link
Copy Markdown
Contributor

What does this PR do?

Refactor options to control grain computation into a single disabled_grains list and make lvm 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.

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.

@agraul
agraul requested a review from a team as a code owner November 25, 2022 11:07
@agraul
agraul requested review from Ch3LL and removed request for a team November 25, 2022 11:07
@agraul
agraul force-pushed the control-lvm-grains-collection-config branch from dfac6d9 to a4bb635 Compare November 25, 2022 11:33
meaksh
meaksh previously approved these changes Nov 25, 2022
Comment thread salt/grains/lvm.py Outdated
@agraul
agraul requested a review from Ch3LL December 13, 2022 17:38
@agraul
agraul force-pushed the control-lvm-grains-collection-config branch from a4bb635 to 20368ac Compare January 4, 2023 16:43
@agraul

agraul commented Jan 4, 2023

Copy link
Copy Markdown
Contributor Author

I did a first implementation of disabled_grains. I'm not totally happy yet because each grain module / function needs to be updated. If we change the structure of disabled_grains to differentiate between grain modules and grain functions, the loader could take care of skipping disabled grains. I'll work on that next.

Comment thread salt/config/__init__.py Outdated

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Contributor

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.

@agraul
agraul force-pushed the control-lvm-grains-collection-config branch from 20368ac to 3710c84 Compare January 5, 2023 07:56
@Ch3LL

Ch3LL commented Jan 9, 2023

Copy link
Copy Markdown
Contributor

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.

@agraul
agraul force-pushed the control-lvm-grains-collection-config branch 2 times, most recently from badc70b to 4c4c083 Compare February 22, 2023 09:28
@agraul

agraul commented Feb 22, 2023

Copy link
Copy Markdown
Contributor Author

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 __virtual__ vs putting it in the loader code. Any opinions on what would be a better fit?

@Ch3LL

Ch3LL commented Mar 23, 2023

Copy link
Copy Markdown
Contributor

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 __virtual__ function but wanted to get your opinion.

@dwoz

dwoz commented Dec 12, 2023

Copy link
Copy Markdown
Contributor

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.

@dwoz dwoz closed this Dec 12, 2023
@dwoz dwoz added help-wanted Community help is needed to resolve this Abandoned labels Dec 12, 2023
@agraul

agraul commented Dec 12, 2023

Copy link
Copy Markdown
Contributor Author

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.

@dwoz dwoz reopened this Dec 16, 2023
@dwoz

dwoz commented Dec 16, 2023

Copy link
Copy Markdown
Contributor

Great, and thanks for the reply. Please re-base and fix the conflicts so we can see if all tests pass.

twangboy
twangboy previously approved these changes Jul 3, 2025
@twangboy twangboy added Tests test:full Run the full test suite and removed Tests Abandoned labels Jul 3, 2025
@twangboy twangboy added the merge-conflict PR has a merge conflict label Aug 6, 2025
@twangboy

Copy link
Copy Markdown
Contributor

Please address the conflicts above

@twangboy twangboy modified the milestones: Argon v3008.0, Argon v3008.1 Jun 5, 2026
@dwoz
dwoz force-pushed the control-lvm-grains-collection-config branch from 7afe6b8 to 35e4315 Compare June 15, 2026 22:46
@dwoz dwoz modified the milestones: Argon v3008.1, Potassium v3009.0 Jun 15, 2026
@dwoz dwoz removed the merge-conflict PR has a merge conflict label Jun 15, 2026
@dwoz
dwoz force-pushed the control-lvm-grains-collection-config branch from 35e4315 to 30f9d53 Compare June 15, 2026 22:50
agraul and others added 3 commits July 1, 2026 12:02
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.
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
Fix lvm.__virtual__() to return __virtualname__ (string) when enabled
rather than True (boolean), matching Salt grain loader conventions.

Add unit tests for __virtual__ enable/disable behavior via disabled_grains.

Add deprecated changelog entry for per-grain enable_* options.

Add deprecation warnings in _update_disabled_grains for Calcium removal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help-wanted Community help is needed to resolve this test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Ability to control if lvm grains are collected

5 participants