Skip to content

Commit

Permalink
fixes #62523 saltcheck doesnt work with pyobjects renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasmhughes authored and Megan Wilhite committed Sep 21, 2022
1 parent cdd1269 commit 95e011d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions salt/modules/saltcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@

log = logging.getLogger(__name__)

global_scheck = None
try:
__context__
except NameError:
__context__ = {}
__context__["global_scheck"] = None

__virtualname__ = "saltcheck"

Expand Down Expand Up @@ -457,8 +461,7 @@ def run_state_tests(state, saltenv=None, check_all=False, only_fails=False):
saltenv = "base"

# Use global scheck variable for reuse in each multiprocess
global global_scheck
global_scheck = SaltCheck(saltenv)
__context__["global_scheck"] = SaltCheck(saltenv)

parallel = __salt__["config.get"]("saltcheck_parallel")
num_proc = __salt__["config.get"]("saltcheck_processes")
Expand Down Expand Up @@ -508,7 +511,7 @@ def run_state_tests(state, saltenv=None, check_all=False, only_fails=False):
results_dict[key] = value
else:
for key, value in stl.test_dict.items():
result = global_scheck.run_test(value)
result = __context__["global_scheck"].run_test(value)
results_dict[key] = result

# If passed a duplicate state, don't overwrite with empty res
Expand All @@ -522,7 +525,7 @@ def parallel_scheck(data):
key = data[0]
value = data[1]
results = {}
results[key] = global_scheck.run_test(value)
results[key] = __context__["global_scheck"].run_test(value)
return results


Expand Down Expand Up @@ -620,7 +623,9 @@ def _render_file(file_path):
call the salt utility to render a file
"""
# salt-call slsutil.renderer /srv/salt/jinjatest/saltcheck-tests/test1.tst
rendered = __salt__["slsutil.renderer"](file_path, saltenv=global_scheck.saltenv)
rendered = __salt__["slsutil.renderer"](
file_path, saltenv=__context__["global_scheck"].saltenv
)
log.info("rendered: %s", rendered)
return rendered

Expand Down

0 comments on commit 95e011d

Please sign in to comment.