mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Don't needlessly refresh fileserver backends during Pillar rendering
This uses the opts key that masterless runs use to limit fileserver backend refreshes to a single refresh. Adding it to the master opts ensures that FSChan instances created on the master do not trigger fileserver backend refreshes.
This commit is contained in:
parent
beb2c6d7b4
commit
adb9397bd6
3 changed files with 72 additions and 0 deletions
2
changelog/65990.fixed.md
Normal file
2
changelog/65990.fixed.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
Fixed an issue where fileclient requests during Pillar rendering cause
|
||||
fileserver backends to be needlessly refreshed.
|
|
@ -3948,6 +3948,14 @@ def apply_master_config(overrides=None, defaults=None):
|
|||
|
||||
opts = defaults.copy()
|
||||
opts["__role"] = "master"
|
||||
|
||||
# Suppress fileserver update in FSChan, for LocalClient instances generated
|
||||
# during Pillar compilation. The master daemon already handles FS updates
|
||||
# in its maintenance thread. Refreshing during Pillar compilation slows
|
||||
# down Pillar considerably (even to the point of timeout) when there are
|
||||
# many gitfs remotes.
|
||||
opts["__fs_update"] = True
|
||||
|
||||
_adjust_log_file_override(overrides, defaults["log_file"])
|
||||
if overrides:
|
||||
opts.update(overrides)
|
||||
|
|
62
tests/unit/test_fileclient.py
Normal file
62
tests/unit/test_fileclient.py
Normal file
|
@ -0,0 +1,62 @@
|
|||
"""
|
||||
:codeauthor: Erik Johnson <palehose@gmail.com>
|
||||
"""
|
||||
|
||||
import salt.config
|
||||
from salt import fileclient
|
||||
from tests.support.mock import MagicMock, patch
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
class FSClientTestCase(TestCase):
|
||||
def _get_defaults(self, **kwargs):
|
||||
"""
|
||||
master/minion config defaults
|
||||
"""
|
||||
ret = {
|
||||
"saltenv": kwargs.pop("saltenv", None),
|
||||
"id": "test",
|
||||
"cachedir": "/A",
|
||||
"sock_dir": "/B",
|
||||
"root_dir": "/C",
|
||||
"fileserver_backend": "roots",
|
||||
"open_mode": False,
|
||||
"auto_accept": False,
|
||||
"file_roots": {},
|
||||
"pillar_roots": {},
|
||||
"file_ignore_glob": [],
|
||||
"file_ignore_regex": [],
|
||||
"worker_threads": 5,
|
||||
"hash_type": "sha256",
|
||||
"log_file": "foo.log",
|
||||
"ssl": True,
|
||||
"file_client": "local",
|
||||
}
|
||||
ret.update(kwargs)
|
||||
return ret
|
||||
|
||||
def test_master_no_fs_update(self):
|
||||
"""
|
||||
Test that an FSClient spawned from the master does not cause fileserver
|
||||
backends to be refreshed on instantiation. The master already has the
|
||||
maintenance thread for that.
|
||||
"""
|
||||
opts = salt.config.apply_master_config(defaults=self._get_defaults())
|
||||
fileserver = MagicMock()
|
||||
|
||||
with patch("salt.fileserver.Fileserver", fileserver):
|
||||
client = fileclient.FSClient(opts)
|
||||
assert client.channel.fs.update.call_count == 0
|
||||
|
||||
def test_masterless_no_fs_update(self):
|
||||
"""
|
||||
Test that an FSClient spawned from a masterless run refreshes the
|
||||
fileserver backends. This is necessary to ensure that a masterless run
|
||||
can access any configured gitfs remotes.
|
||||
"""
|
||||
opts = salt.config.apply_minion_config(defaults=self._get_defaults())
|
||||
fileserver = MagicMock()
|
||||
|
||||
with patch("salt.fileserver.Fileserver", fileserver):
|
||||
client = fileclient.FSClient(opts)
|
||||
assert client.channel.fs.update.call_count == 1
|
Loading…
Add table
Reference in a new issue