From 559825c92249da630e95c2034ed19d01854ce823 Mon Sep 17 00:00:00 2001 From: Thomas Phipps Date: Tue, 9 Apr 2024 16:48:17 +0000 Subject: [PATCH] remove backwords compatibility. internally salt doesn't need it. and if someone is using PillarCache incorrectly that is on them. --- salt/pillar/__init__.py | 9 +++------ tests/pytests/unit/pillar/test_pillar.py | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/salt/pillar/__init__.py b/salt/pillar/__init__.py index c4653d8a558..02b1006b5ef 100644 --- a/salt/pillar/__init__.py +++ b/salt/pillar/__init__.py @@ -460,15 +460,12 @@ class PillarCache: """ return os.path.join(self.opts["cachedir"], "pillar_cache", minion_id) - def fetch_pillar(self, save_override=True): + def fetch_pillar(self): """ In the event of a cache miss, we need to incur the overhead of caching a new pillar. """ log.debug("Pillar cache getting external pillar with ext: %s", self.ext) - override = None - if save_override: - override = self.pillar_override fresh_pillar = Pillar( self.opts, self.grains, @@ -476,7 +473,7 @@ class PillarCache: self.saltenv, ext=self.ext, functions=self.functions, - pillar_override=override, + pillar_override=None, pillarenv=self.pillarenv, extra_minion_data=self.extra_minion_data, ) @@ -531,7 +528,7 @@ class PillarCache: return fresh_pillar else: # We haven't seen this minion yet in the cache. Store it. - fresh_pillar = self.fetch_pillar(save_override=False) + fresh_pillar = self.fetch_pillar() self.cache[self.minion_id] = {self.pillarenv: fresh_pillar} log.debug("Pillar cache miss for minion %s", self.minion_id) log.debug("Current pillar cache: %s", cache_dict) # FIXME hack! diff --git a/tests/pytests/unit/pillar/test_pillar.py b/tests/pytests/unit/pillar/test_pillar.py index 3ee5892d3b4..763739f9193 100644 --- a/tests/pytests/unit/pillar/test_pillar.py +++ b/tests/pytests/unit/pillar/test_pillar.py @@ -164,7 +164,7 @@ def test_pillar_get_cache_disk(temp_salt_minion, caplog): assert fresh_pillar == {} -def test_pillar_save_cache(temp_salt_minion, caplog): +def test_pillar_fetch_pillar_override_skipped(temp_salt_minion, caplog): with pytest.helpers.temp_directory() as temp_path: tmp_cachedir = Path(str(temp_path) + "/pillar_cache/") tmp_cachedir.mkdir(parents=True) @@ -188,10 +188,8 @@ def test_pillar_save_cache(temp_salt_minion, caplog): pillar_override=pillar_override, ) - fresh_pillar = pillar.fetch_pillar(save_override=False) + fresh_pillar = pillar.fetch_pillar() assert fresh_pillar == {} - fresh_pillar2 = pillar.fetch_pillar() - assert fresh_pillar2 == pillar_override def test_remote_pillar_timeout(temp_salt_minion, tmp_path):