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

fengine should return non-zero code if render fails #351

Open
edgrz opened this issue Jun 21, 2023 · 0 comments
Open

fengine should return non-zero code if render fails #351

edgrz opened this issue Jun 21, 2023 · 0 comments

Comments

@edgrz
Copy link

edgrz commented Jun 21, 2023

Using fengine to render a template folder is always returning zero as exit code regardless of whether or not render was successful.

For instance:

I have a ci/cd job in gitlab that builds the template and stores it as an artifact. It uses directly the fengine package to render files and inspecting the fengine logs during the process we can clearly notice it failed:

2023-06-21 08:51:13 [error    ] initialization failed: ...

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/foxops/engine/__main__.py", line 120, in cmd_initialize
    asyncio.run(
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/foxops/engine/initialization.py", line 38, in initialize_incarnation
    return await _initialize_incarnation(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/foxops/engine/initialization.py", line 88, in _initialize_incarnation
    await render_template(
  File "/usr/local/lib/python3.11/site-packages/foxops/engine/rendering.py", line 106, in render_template
    await _render_template_file(
  File "/usr/local/lib/python3.11/site-packages/foxops/engine/rendering.py", line 85, in _render_template_file
    return await render_template_file(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/foxops/engine/rendering.py", line 130, in render_template_file
    rendered_content = await content_template.render_async(**template_data)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line [132]()4, in render_async
    return self.environment.handle_exception()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1321, in <listcomp>
    [n async for n in self.root_render_func(ctx)]  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/template/xxxx/regenerate_cronjob.yaml", line 19, in top-level template code
    {{ someop()|indent(8) }}
  File "/usr/local/lib/python3.11/site-packages/jinja2/async_utils.py", line 65, in auto_await
    return await t.cast("t.Awaitable[V]", value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/runtime.py", line 766, in _async_invoke
    rv = await self._func(*arguments)  # type: ignore
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/templates/xxxx/regenerate_cronjob.yaml", line 18, in template
    {%- macro someop() %}{% include "/base/job_template.yaml.j2" %}{% endmacro %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/loaders.py", line 218, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: /base/job_template.yaml.j2

However, the process is returning exit code 0, so job reports as success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant