Skip to content
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

[3007.x] fix sync_renderers failure when the custom renderer is specified via config #66454

Open
wants to merge 5 commits into
base: 3007.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/66453.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix sync_renderers failure when the custom renderer is specified via config
15 changes: 14 additions & 1 deletion salt/loader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,20 @@ def render(
"the needed software is unavailable".format(opts["renderer"])
)
log.critical(err)
raise LoaderError(err)
if opts.get("__role") == "minion":
default_renderer_config = salt.config.DEFAULT_MINION_OPTS["renderer"]
else:
default_renderer_config = salt.config.DEFAULT_MASTER_OPTS["renderer"]
log.warning(
"Attempting fallback to default render pipe: %s", default_renderer_config
)
if not check_render_pipe_str(
default_renderer_config,
rend,
opts["renderer_blacklist"],
opts["renderer_whitelist"],
):
raise LoaderError(err)
return rend


Expand Down
17 changes: 17 additions & 0 deletions tests/pytests/unit/loader/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

import pytest

import salt.config
import salt.exceptions
import salt.loader
import salt.loader.lazy
from tests.support.mock import MagicMock, patch


@pytest.fixture
Expand Down Expand Up @@ -85,6 +87,21 @@ def foobar():
loader["mymod.foobar"]()


def test_render():
opts = salt.config.DEFAULT_MINION_OPTS.copy()
minion_mods = salt.loader.minion_mods(opts)
for role in ["minion", "master"]:
opts["__role"] = role
for renderer in ["jinja|yaml", "some_custom_thing"]:
opts["renderer"] = renderer
ret = salt.loader.render(opts, minion_mods)
assert isinstance(ret, salt.loader.lazy.FilterDictWrapper)
with pytest.raises(salt.exceptions.LoaderError), patch(
"salt.loader.check_render_pipe_str", MagicMock(side_effect=[False, False])
):
salt.loader.render(opts, minion_mods)


def test_return_named_context_from_loaded_func(tmp_path):
opts = {
"optimization_order": [0],
Expand Down
Loading