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

Imported jinja without context in .sls are not cached #66485

Open
2 of 9 tasks
baby-gnu opened this issue May 7, 2024 · 0 comments
Open
2 of 9 tasks

Imported jinja without context in .sls are not cached #66485

baby-gnu opened this issue May 7, 2024 · 0 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@baby-gnu
Copy link

baby-gnu commented May 7, 2024

Description

When doing an import of a Jinja from a .sls without passing context should be cached according to Jinja template but it seems to not be the case.

Setup

Install latest onedir on Debian 12 according to documentation

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (KVM)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior

  • create a /srv/salt/test-cache/init.sls
    include:
      - .test1
      - .test2
  • create the /srv/salt/test-cache/test1.sls
    {%- profile as 'load slow-sha-compute from test1' %}
    {%-   from "test-cache/slow-compute.jinja" import slow_value %}
    {%- endprofile %}
    
    test1-show-slow-value:
      test.nop:
        - name: {{ slow_value }}
  • create the /srv/salt/test-cache/test2.sls
    {%- profile as 'load slow-sha-compute from test2' %}
    {%-   from "test-cache/slow-compute.jinja" import slow_value %}
    {%- endprofile %}
    
    test2-show-slow-value:
      test.nop:
        - name: {{ slow_value }}
  • create the jinja file /srv/salt/test-cache/slow-compute.sls
    {%- do salt["test.sleep"](10) %}
    {%- set slow_value = "10" %}
  • execute the command salt-call -l profile state.apply test-cache
    [WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
    [INFO    ] Loading fresh modules for state activity
    [PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/test-cache/init.sls' using 'jinja' renderer: 0.0031363964080810547
    [PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/test-cache/init.sls' using 'yaml' renderer: 0.0005271434783935547
    [PROFILE ] Time (in seconds) to render profile block 'load slow-sha-compute from test1': 10.01871919631958
    [PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/test-cache/test1.sls' using 'jinja' renderer: 10.022127628326416
    [PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/test-cache/test1.sls' using 'yaml' renderer: 0.0008547306060791016
    [PROFILE ] Time (in seconds) to render profile block 'load slow-sha-compute from test2': 10.018997192382812
    [PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/test-cache/test2.sls' using 'jinja' renderer: 10.021836757659912
    [PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/test-cache/test2.sls' using 'yaml' renderer: 0.0007636547088623047
    [INFO    ] Running state [test1-show-slow-value] at time 17:00:44.647191
    [INFO    ] Executing state test.nop for [test1-show-slow-value]
    [INFO    ] Success!
    [INFO    ] Completed state [test1-show-slow-value] at time 17:00:44.648329 (duration_in_ms=1.14)
    [INFO    ] Running state [test2-show-slow-value] at time 17:00:44.648555
    [INFO    ] Executing state test.nop for [test2-show-slow-value]
    [INFO    ] Success!
    [INFO    ] Completed state [test2-show-slow-value] at time 17:00:44.649393 (duration_in_ms=0.839)
    local:
    ----------
              ID: test1-show-slow-value
        Function: test.nop
          Result: True
         Comment: Success!
         Started: 17:00:44.647189
        Duration: 1.14 ms
         Changes:
    ----------
              ID: test2-show-slow-value
        Function: test.nop
          Result: True
         Comment: Success!
         Started: 17:00:44.648554
        Duration: 0.839 ms
         Changes:
    
    Summary for local
    ------------
    Succeeded: 2
    Failed:    0
    ------------
    Total states run:     2
    Total run time:   1.979 ms
    

Expected behavior

The rendering of /srv/salt/test-cache/slow-compute.jinja show be quick when loaded from /srv/salt/test-cache/test2.sls instead of during more than 10 seconds.

Screenshots

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3007.0
 
Python Version:
        Python: 3.10.13 (main, Feb 19 2024, 03:31:20) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.16.0
      cherrypy: unknown
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.3
       libgit2: 1.7.2
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.7
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.1
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: 1.14.1
  python-gnupg: 0.5.2
        PyYAML: 6.0.1
         PyZMQ: 25.1.2
        relenv: 0.15.1
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 6.3.3
           ZMQ: 4.3.4
 
Salt Package Information:
  Package Type: onedir
 
System Versions:
          dist: debian 12.5 bookworm
        locale: utf-8
       machine: x86_64
       release: 6.1.0-12-cloud-amd64
        system: Linux
       version: Debian GNU/Linux 12.5 bookworm

Additional context

Following #59441 for 3007.0 with simpler instruction by using salt["test.sleep"](10) instead of complicated ISO hash computation.

@baby-gnu baby-gnu added Bug broken, incorrect, or confusing behavior needs-triage labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant