Skip to content

Commit

Permalink
address circular reference in LazyLoader with ThreadLocalProxy
Browse files Browse the repository at this point in the history
when lazyLoader was getting instantiated from inside already lazyloaded
modules (ie state), pillar/grain (and probably other) globals were
already populated. In this case they weren't getting dereferenced
properly when wrapped via the NamespacedDict wrapper, causing an
infinite loop. This should fix that scenario.

Fixes saltstack#50655 (comment)
  • Loading branch information
mattp- authored and Ken Crowell committed Dec 4, 2019
1 parent e96c0fa commit 2202fed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/integration/files/file/base/issue-51499.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% if 'nonexistent_module.function' in salt %}
{% do salt.log.warning("Module is available") %}
{% endif %}
always-passes:
test.succeed_without_changes:
- name: foo
13 changes: 13 additions & 0 deletions tests/integration/modules/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2118,3 +2118,16 @@ def test_state_sls_integer_name(self):
self.assertEqual(state_run[state_id]['comment'],
'Success!')
self.assertTrue(state_run[state_id]['result'])

def test_state_sls_lazyloader_allows_recursion(self):
'''
This tests that referencing dunders like __salt__ work
context: https://github.com/saltstack/salt/pull/51499
'''
state_run = self.run_function('state.sls', mods='issue-51499')

state_id = 'test_|-always-passes_|-foo_|-succeed_without_changes'
self.assertIn(state_id, state_run)
self.assertEqual(state_run[state_id]['comment'],
'Success!')
self.assertTrue(state_run[state_id]['result'])

0 comments on commit 2202fed

Please sign in to comment.