-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix(libtofs): “files_switch” mess up the variable exported by “map.jinja” #187
fix(libtofs): “files_switch” mess up the variable exported by “map.jinja” #187
Conversation
a2d4a47
to
e1629a1
Compare
e1629a1
to
3dc1f03
Compare
I need to find a way to |
3dc1f03
to
80d58d2
Compare
- “map.jinja” export a variable name as “<tplroot>” - import of “libtofs.jinja” is done with context and has access to “<tplroot>” variable - in “files_switch”, appending the empty string to the “fsl” variable modify globally “<tplroot>['tofs']['files_switch']” * TEMPLATE/libtofs.jinja: do not use inplace “append” to avoid side effect.
80d58d2
to
ab4ce75
Compare
I think it's better to just avoid inplace |
@baby-gnu Is this ready for review now? |
Yes, this fix is finished. |
The only hypothesis I have for this problem is that Combined with possible differences between |
@baby-gnu Try as I might, I can't reproduce the original issue. Would you mind sharing the steps to reproduce it? I've tested the changes and the output of the map before and after are identical (using [ERROR ] map
added_in_defaults: defaults_value
added_in_lookup: lookup_value
added_in_pillar: pillar_value
arch: amd64
config: /etc/template-formula.conf
lookup:
added_in_lookup: lookup_value
master: template-master
winner: lookup
master: template-master
pkg:
name: bash
rootgroup: root
service:
name: systemd-udevd
subcomponent:
config: /etc/TEMPLATE-subcomponent-formula.conf
tofs:
files_switch:
- any/path/can/be/used/here
- id
- roles
- osfinger
- os
- os_family
source_files:
TEMPLATE-config-file-file-managed:
- example.tmpl.jinja
TEMPLATE-subcomponent-config-file-file-managed:
- subcomponent-example.tmpl.jinja |
@baby-gnu OK, I'll try that when I get a chance. |
I discovered the problem when implementing #186, there is a trailing In the failing logs we have:
To reproduce:
Here is the debug output of
To prove that several calls to # -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set TEST_VAR = salt.config.get('TEST', {}) %}
{%- do salt.log.debug('TEST_VAR is: ' ~ TEST_VAR) %}
{%- set TEST_VAR2 = salt.config.get('TEST', {}) %}
{%- do salt.log.debug('TEST_VAR2 is: ' ~ TEST_VAR2) %}
{%- set fsl = TEST_VAR2['tofs']['files_switch'] %}
{%- do salt.log.debug('fsl is: ' ~ fsl) %}
{%- do fsl.append('x') %}
{%- do salt.log.debug('fsl after append is: ' ~ fsl) %}
{%- do salt.log.debug('TEST_VAR after append is: ' ~ TEST_VAR) %}
{%- do salt.log.debug('TEST_VAR2 after append is: ' ~ TEST_VAR2) %}
{%- set TEST_VAR3 = salt.config.get('TEST', {}) %}
{%- do salt.log.debug('TEST_VAR3 is: ' ~ TEST_VAR3) %}
Test which do nothing:
test.nop:
- name: {{ TEST_VAR }} Here is the output of
|
@baby-gnu Thanks for the detailed explanation, I was finally able to reproduce it locally (and confirm the fix), but only when using |
🎉 This PR is included in version 4.0.4 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
@baby-gnu The change has been propagated throughout the formulas using myii/ssf-formula#131. |
Thanks a lot @myii |
PR progress checklist (to be filled in by reviewers)
What type of PR is this?
Primary type
[build]
Changes related to the build system[chore]
Changes to the build process or auxiliary tools and libraries such as documentation generation[ci]
Changes to the continuous integration configuration[feat]
A new feature[fix]
A bug fix[perf]
A code change that improves performance[refactor]
A code change that neither fixes a bug nor adds a feature[revert]
A change used to revert a previous commit[style]
Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)Secondary type
[docs]
Documentation changes[test]
Adding missing or correcting existing testsDoes this PR introduce a
BREAKING CHANGE
?No.
Related issues and/or pull requests
This fix was exposed by #186 and must be merged before it.
Describe the changes you're proposing
files_switch
mess up the variable exported bymap.jinja
map.jinja
export a variable name as<tplroot>
libtofs.jinja
is done with context and has access to<tplroot>
variablefiles_switch
, appending the empty string to thefsl
variable modify globally<tplroot>['tofs']['files_switch']
TEMPLATE/libtofs.jinja
: initialisefsl
with a copy offiles_switch_list
instead of a reference.Pillar / config required to test the proposed changes
Debug log showing how the proposed changes work
Documentation checklist
README
(e.g.Available states
).pillar.example
.Testing checklist
state_top
).Additional context