File control-the-collection-of-lvm-grains-via-config.patch of Package salt

From fcb43735942ca1b796f656d5647e49a93f770bb2 Mon Sep 17 00:00:00 2001
From: Alexander Graul <agraul@suse.com>
Date: Tue, 10 Jan 2023 15:04:01 +0100
Subject: [PATCH] Control the collection of lvm grains via config

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 setting

    enable_lvm_grains: False
---
 salt/grains/lvm.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/salt/grains/lvm.py b/salt/grains/lvm.py
index 586b187ddb..f5c406cb44 100644
--- a/salt/grains/lvm.py
+++ b/salt/grains/lvm.py
@@ -17,6 +17,10 @@ __salt__ = {
 log = logging.getLogger(__name__)
 
 
+def __virtual__():
+    return __opts__.get("enable_lvm_grains", True)
+
+
 def lvm():
     """
     Return list of LVM devices
-- 
2.39.2


openSUSE Build Service is sponsored by