-
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
[BUG] 3006.5 "grains" extmods folder cleaned in unexpected situations #65692
Comments
There's a test failure that can be traced back to the mentioned PR as well: #65574 I haven't had the motivation to grok the tested module or the test yet, but it might be related to this as well. |
@lomeroe Can you include an example of the custom grain, want to duplicate exactly the issue you are seeing, that is, the custom grain is part of the steps to reproduce it. |
The EC2 info grain is one of many we distribute, but publicly available, all the others are pretty custom/specific to our environment... https://github.com/vmware-archive/salt-contrib/blob/master/grains/ec2_info.py |
Looking for a simple contents of /srv/salt/_grains which shows the issue |
btw: with /srv/salt/_grains/test_grains.py, the directory is not /var/cache/salt/minion/grains but
And this with Salt 3005.4, but confirmed saltutil.sync_grains on Salt 3006.5 wipes it out from salt-master, |
Suspect the issue is due to bae0321 and not #65574 which didn't change sync_grains, just ensured it was called. Note: issue exists in Salt 3006.4 which being a CVE implies 3006.3 too. Only difference between salt-call --local and salt-call is that '--local' does not contact the salt-master. Investigating further |
We are also seeing this (well, we were; we've since rolled back to 3006.4). For better or worse, we sometimes make decisions in I didn't have too much time to debug, but some observations:
If there's other information that is useful to repro, please let me know. |
Duplicated issue with salt-master and salt-minion using Salt 3006.3. This rules out #65186 as the problem since this was a fix introduced in 3006.5 Also Salt 3006.1 and Salt 3006.0 used for salt-master and salt-minion exhibit the issue. Using Salt 3005.4 for salt-master and salt-minion, the same issue is exhibited, this inclines me to either believe it is a long standing issue unrelated to Salt 3006.x, or functioning as designed. So Salt 3005.4 tiamat-backend on salt-master and salt-minion exhibits the issue, but classic package Salt 3005.4 salt-master and salt-minion do not exhibit the problem if on the same machine, but if the salt-master is on a different machine, then the issue is exhibited (this is probably more an issue with local salt-master or remote salt-master). Have to determine if this is normal operation (operating as designed) or an undiscovered issue |
@dmurphy18 I'm maybe mistaken with the tests you are doing but I don't see this behavior in 3006.4 |
3006.5 is entirely unusable for us due to this. We manually |
+100 |
The whole pillar and grain sync\refresh is way overcomplicated in salt. In some places, you can control it in some, you can't(hello, highstate!). It would be so much simpler if Salt would:
With that implemented we could start each rollout with: sync, refresh, apply and guarantee that it would happen only once. |
@Oloremo I cannot see the way sync refresh in Salt changing, certainly not at this point with the reduced team size. @CapBananoid Here is the test file I am using to test with
Very simple and it occurs on all versions of Salt I have tried with, on Ubuntu 22.04 (master), Centos 7 (master) and Ubuntu 20.04 (minion), with all flavors of 3006.x, and 3005.4 tiamat-backed and classic, with the simple commands:
Interestingly if the salt-master is local (on the same machine) then the cached value is kept (master is not remote being the reason in the code). So I may have found a different issue, hence @lomeroe I need a simple example of usage and repeatability for the issue to ensure I am addressing your issue found, in case it is different from what I have found. |
@frebib Telling me it is entirely broken without providing examples of the issue and ways to demonstrate the issue, is not helpful in getting the issue fixed. It is open-source,therefore please be helpful in assisting the fixing of issues, just telling me it doesn't work, does not help. I get you are having an issue, otherwise you would not have commented, but I need details in order to fix the issue that you are having, and not second guess that it might be one thing or another. Resources on the Salt Core team were never plentiful, and have been sorely reduced recently, so any help /assistance is needed to resolve issues. Not intending to just pick you out, but this applies to all issues going forward. |
From what I understand, the new issue is that custom grain modules sometimes disappear from Lines 133 to 136 in 53c7e6b
Syncing modules with Just my 5ct, I haven't upgraded to 3006.5 yet. Edit (clarification): |
@lkubb I am making it happen on 3005.4 even, so that code was added for 3006.5, so I may have found a different issue in my testing, hence the need for the originators example, or others showing what exactly they are doing to exhibit the problem. |
Egg on face or PBKAC, had the custom grain on the minion and not on the master 🤦 All the more reason to get examples of issue from originators, since core team members can screw it up, esp. after the last couple of weeks 😆 |
@dmurphy18 I cannot reproduce this on $ cat /srv/salt/_grains/foo.py
def foo():
return {"foo": "bar"}
$ salt testminion saltutil.sync_all
testminion:
----------
beacons:
clouds:
engines:
executors:
grains:
- grains.foo
log_handlers:
matchers:
modules:
output:
proxymodules:
renderers:
returners:
sdb:
serializers:
states:
thorium:
utils:
$ salt testminion grains.get foo
testminion:
bar Then switch to $ salt-call grains.get foo
local:
$ salt-call saltutil.sync_all
local:
----------
beacons:
clouds:
engines:
executors:
grains:
- grains.foo
log_handlers:
matchers:
modules:
output:
proxymodules:
renderers:
returners:
sdb:
serializers:
states:
thorium:
utils:
$ salt-call saltutil.sync_all
local:
----------
beacons:
clouds:
engines:
executors:
grains:
- grains.foo
log_handlers:
matchers:
modules:
output:
proxymodules:
renderers:
returners:
sdb:
serializers:
states:
thorium:
utils:
# etc. It keeps resyncing the module when Maybe someone experiencing this issue in Edit: If this is actually the issue, it might be possible to work around it by setting |
So with the custom grains now on the salt-master, noticed that using '--local' on Salt 3006.4 minion also removes the cached value
Also noticed that it was the upgrade from 3006.4 to 3006.5 that wiped out the cached value, this did not occur with an upgrade from 3006.3 to 3006.4 on the salt-minion. The issue of salt-call --local saltutil.sync.grains removing the custom grain cache value is correct, since the custom grain doesn't exist on the salt-minion and the salt-master is not contacted due to the '--local' Will look at why the upgrade to Salt 3006.5 on the salt-minion is wiping the cached value. The fix in #65186 needs to be adjusted or removed, investigating how to fix this incomplete fix |
Imho a simple fix for the issue referenced by the PR would be to document prominently and explicitly that you always need to sync custom modules (once after a change) if you want to use them (including during pillar compilation, this is true when using a master as well) – the exception being custom grain modules in a regular Salt setup (but not in masterless/standalone mode). In essence, the referenced issue is about saving a single |
apologies for taking a few days to get back to this... here's a "scenario 1" test script, as opposed to using a master, this uses an alternative "local" configuration to only require 1 system and not have to configure/setup the master, but the result is the same if you were to setup a master instead...
my 3006.4 output from the test script:
my output from the test script with 3006.5
EDIT TO ADD: also notice output of 3006.5 does not show the grain as being sync'd, even though the "ls" of the /var/cache/salt/minion/extmods/grains folder shows the file exists after the "sync_all" is called |
@dmurphy18 I don't quite follow if your above analysis would cover such behavior for a minion which can talk to its master successfully, so I thought I'd add my experience here. |
Closing this since the custom grains change in Salt 3006.5 has been reverted in #65738 which should be available in 3006.6 when it is released. |
Facing this issue too, we rolled back to 3006.4 |
3006.6 landed a little bit ago. They occasionally return data if I run If I run |
@darkpixel 3006.6 is a CVE release and does not contain the fix for this issue. |
A patch for 3006.5/6: {% if grains.saltversion in ["3006.5", "3006.6"] %}
patch:
pkg.installed
grains_sync_patch:
file.patch:
- name: '{{ grains.saltpath }}'
- source: salt://65738.diff
- strip: 2
- require:
- pkg: patch
restart_salt_minion:
cmd.run:
- name: 'salt-call service.restart salt-minion'
- bg: true
- onchanges:
- file: grains_sync_patch
{%- endif %} 65738.diffdiff --git a/salt/fileclient.py b/salt/fileclient.py
index 42e7120aab18..443861cc03fd 100644
--- a/salt/fileclient.py
+++ b/salt/fileclient.py
@@ -45,15 +45,12 @@
MAX_FILENAME_LENGTH = 255
-def get_file_client(opts, pillar=False, force_local=False):
+def get_file_client(opts, pillar=False):
"""
Read in the ``file_client`` option and return the correct type of file
server
"""
- if force_local:
- client = "local"
- else:
- client = opts.get("file_client", "remote")
+ client = opts.get("file_client", "remote")
if pillar and client == "local":
client = "pillar"
diff --git a/salt/minion.py b/salt/minion.py
index 0c5c77a91e50..15d46b2dacf9 100644
--- a/salt/minion.py
+++ b/salt/minion.py
@@ -114,29 +114,6 @@
# 6. Handle publications
-def _sync_grains(opts):
- # need sync of custom grains as may be used in pillar compilation
- # if coming up initially and remote client, the first sync _grains
- # doesn't have opts["master_uri"] set yet during the sync, so need
- # to force local, otherwise will throw an exception when attempting
- # to retrieve opts["master_uri"] when retrieving key for remote communication
- # in addition opts sometimes does not contain extmod_whitelist and extmod_blacklist
- # hence set those to defaults, empty dict, if not part of opts, as ref'd in
- # salt.utils.extmod sync function
- if opts.get("extmod_whitelist", None) is None:
- opts["extmod_whitelist"] = {}
-
- if opts.get("extmod_blacklist", None) is None:
- opts["extmod_blacklist"] = {}
-
- if opts.get("file_client", "remote") == "remote" and not opts.get(
- "master_uri", None
- ):
- salt.utils.extmods.sync(opts, "grains", force_local=True)
- else:
- salt.utils.extmods.sync(opts, "grains")
-
-
def resolve_dns(opts, fallback=True):
"""
Resolves the master_ip and master_uri options
@@ -944,7 +921,6 @@ def __init__(self, opts, context=None):
# Late setup of the opts grains, so we can log from the grains module
import salt.loader
- _sync_grains(opts)
opts["grains"] = salt.loader.grains(opts)
super().__init__(opts)
diff --git a/salt/utils/extmods.py b/salt/utils/extmods.py
index 6a4d5c14440c..a7dc265476f5 100644
--- a/salt/utils/extmods.py
+++ b/salt/utils/extmods.py
@@ -39,7 +39,6 @@ def sync(
saltenv=None,
extmod_whitelist=None,
extmod_blacklist=None,
- force_local=False,
):
"""
Sync custom modules into the extension_modules directory
@@ -83,9 +82,7 @@ def sync(
"Cannot create cache module directory %s. Check permissions.",
mod_dir,
)
- with salt.fileclient.get_file_client(
- opts, pillar=False, force_local=force_local
- ) as fileclient:
+ with salt.fileclient.get_file_client(opts) as fileclient:
for sub_env in saltenv:
log.info("Syncing %s for environment '%s'", form, sub_env)
cache = []
|
Yeah. I feel kinda stupid. I got all excited that a batch of issues I've been having with the last 3 versions of Salt were finally going to be solved. Then I looked at the changelog. ;) |
the breakage in Salt 3006.5 has been rolled back and normal grains should be available in the next bug release which will be soon, had to get the CVE release out first |
saltstack/salt#65692 temporarily until the fix for this bug is released in 3006.7
saltstack/salt#65692 temporarily until the fix for this bug is released in 3006.7
saltstack/salt#65692 temporarily until the fix for this bug is released in 3006.7
saltstack/salt#65692 temporarily until the fix for this bug is released in 3006.7
saltstack/salt#65692 temporarily until the fix for this bug is released in 3006.7
Description
In 3006.5, the extmods grains folder is removed in many situations:
when the
--local
option is passed to asalt-call
command and the minion has previously sync'd grains from a master, losing all previously synchronized grain modulesThe folder also seems to be removed if the minion cannot connect to the master. I.E. a mastered minion, whose master is down, will clean its grains folder and lose all sync'd grains until the master is "alive" again and they can be resync'd.
The folder is removed on other commands, even when the master is alive, for example,
salt-call test.ping
will remove the grains extmods folder and the minion will lose sync'd grains.Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)
Please be as specific as possible and give set-up details.
Steps to Reproduce the behavior
Situation 1:
"--local" option
configure a minion with a master that provides additional grain modules via the _grains folder
sync the grains from the master
salt-call saltutil.sync_grains
orsalt-call saltutil.sync_all
, /var/cache/salt/minion/grains should have the grains modules from the _grains folder on the masteruse
salt-call --local <anything>
and the /var/cache/salt/minion/grains folder will be removed - other extmods folders (like modules, states, etc do not seem to be affected).Situation 2:
module commands:
salt-call saltutil.sync_all
extmods grains folder existssalt-call test.ping
grains extmods folder is removed (other modules tested where extmods grains folder is removed: grains.get, grains.itemsSituation 3:
master is down
salt-call saltutil.sync_all
- extmods grains folder exists..take master offline..
salt-call grains.items
- extmods grains folder is removedExpected behavior
The grains extmods folder is not cleaned in any of the specified scenarios.
Screenshots
If applicable, add screenshots to help explain your problem.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Additional context
Based on 3006.5 release notes alone, I would suspect this is a side effect of #65186
A minion that is explicitly configured as "local" does not seem to exhibit any of these symptoms.
The text was updated successfully, but these errors were encountered: