Skip to content

[BUG] Salt minion is not caching all the formula's files on windows machines #79

@fgionghi

Description

@fgionghi

Your setup

Formula commit hash / release tag

Release tag: 0.14.0

Versions reports (master & minion)

Salt master:

Salt Version:
          Salt: 3003.3
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.7.3
     docker-py: Not Installed
         gitdb: 2.0.6
     gitpython: 3.0.7
        Jinja2: 2.10.1
       libgit2: 0.28.3
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.6.1
        pygit2: 1.0.3
        Python: 3.8.10 (default, Jun  2 2021, 10:49:15)
  python-gnupg: 0.4.5
        PyYAML: 5.3.1
         PyZMQ: 18.1.1
         smmap: 2.0.5
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.2
 
System Versions:
          dist: ubuntu 20.04 focal
        locale: utf-8
       machine: x86_64
       release: 5.8.0-59-generic
        system: Linux
       version: Ubuntu 20.04 focal

Salt minion:

Salt Version:
          Salt: 3003.3

Dependency Versions:
          cffi: 1.14.5
      cherrypy: 18.6.0
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: 4.0.5
     gitpython: 3.1.13
        Jinja2: 2.11.3
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: 1.1.4
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.20
      pycrypto: Not Installed
  pycryptodome: 3.9.8
        pygit2: Not Installed
        Python: 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
  python-gnupg: 0.4.6
        PyYAML: 5.4.1
         PyZMQ: 18.0.1
         smmap: 3.0.4
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.1

System Versions:
          dist:
        locale: cp1252
       machine: AMD64
       release: 10
        system: Windows
       version: 10 10.0.19041 SP0

Pillar / config used

packages:
  chocolatey:
    wanted:
      prometheus-windows-exporter.install:
        version: '0.16.0'

Bug details

Describe the bug

When I run the command salt skyros.pc.itc.it state.test packages.chocolatey, I get the error:

skyros.pc.itc.it:                                                                                         
    Data failed to compile:                                                                               
----------                                                                                                
    Rendering SLS 'base:packages.chocolatey' failed: Jinja error: ./map.jinja                             
Traceback (most recent call last):                                                                        
  File "c:\salt\bin\lib\site-packages\salt-3003.3-py3.7.egg\salt\utils\templates.py", line 500, in render_
jinja_tmpl                                                                                                
    output = template.render(**decoded_context)                                                           
  File "c:\salt\bin\lib\site-packages\jinja2\environment.py", line 1090, in render                        
    self.environment.handle_exception()                                                                   
  File "c:\salt\bin\lib\site-packages\jinja2\environment.py", line 832, in handle_exception               
    reraise(*rewrite_traceback_stack(source=source))                                                      
  File "c:\salt\bin\lib\site-packages\jinja2\_compat.py", line 28, in reraise                             
    raise value.with_traceback(tb)                                                                        
  File "<template>", line 3, in top-level template code                                                   
  File "c:\salt\bin\lib\site-packages\salt-3003.3-py3.7.egg\salt\utils\jinja.py", line 198, in get_source 
    raise TemplateNotFound(template)                                                                      
jinja2.exceptions.TemplateNotFound: ./map.jinja                                                           
                                                                                                          
; line 3                                                                                                  
                                                                                                          
---                                                                                                       
# -*- coding: utf-8 -*-                                                                                   
# vim: ft=sls                                                                                             
{%- from "./map.jinja" import packages with context %}    <======================                         
                                                                                                          
{%- if grains['os'] == 'Windows' %}                                                                       
                                                                                                          
  {%- if packages.chocolatey %}                                                                           
    {%- set req_states = packages.chocolatey.required.states %}                                           
[...]                                                                                                     
---                                                                                                       
ERROR: Minions returned with non-zero exit code

and in the cache folder on the target (C:\salt\var\cache\salt\minion\files\base\packages) the only file is chocolately.sls without any map.jinja

We tried with different version of salt-minion, with different windows version (win10, win server 2016/2019) and with two different salt-master (same version of salt-master).

When I run salt skyros.pc.itc.it state.test packages in the cache folder on the target machine I have more files (for example the map.jinja) but not all files (the default.yaml is missing). In fact I get multiple errors regarding the default.yaml file, like this:

----------                                                                                                
    Rendering SLS 'base:packages.golang.goget' failed: Jinja error: ./defaults.yaml                       
c:\salt\var\cache\salt\minion\files\base\packages/map.jinja(4):                                           
---                                                                                                       
# -*- coding: utf-8 -*-                                                                                   
# vim: ft=jinja                                                                                           
                                                                                                          
{%- import_yaml './defaults.yaml' as defaults %}    <======================                               
{%- import_yaml './osfamilymap.yaml' as osfamilymap %}                                                    
{%- import_yaml './osmap.yaml' as osmap %}                                                                
{%- import_yaml './osfingermap.yaml' as osfingermap %}                                                    
                                                                                                          
{%- set packages = salt['grains.filter_by'](                                                              
[...]                                                                                                     
---                                                                                                       
Traceback (most recent call last):                                                                        
  File "c:\salt\bin\lib\site-packages\salt-3003.3-py3.7.egg\salt\utils\templates.py", line 500, in render_
jinja_tmpl                                                                                                
    output = template.render(**decoded_context)                                                           
  File "c:\salt\bin\lib\site-packages\jinja2\environment.py", line 1090, in render                        
    self.environment.handle_exception()                                                                   
  File "c:\salt\bin\lib\site-packages\jinja2\environment.py", line 832, in handle_exception               
    reraise(*rewrite_traceback_stack(source=source))                                                      
  File "c:\salt\bin\lib\site-packages\jinja2\_compat.py", line 28, in reraise                             
    raise value.with_traceback(tb)                                                                        
  File "<template>", line 6, in top-level template code                                                   
  File "c:\salt\bin\lib\site-packages\jinja2\environment.py", line 1155, in make_module                   
    return TemplateModule(self, self.new_context(vars, shared, locals))                                   
  File "c:\salt\bin\lib\site-packages\jinja2\environment.py", line 1238, in __init__                      
    body_stream = list(template.root_render_func(context))                                                
  File "c:\salt\var\cache\salt\minion\files\base\packages/map.jinja", line 4, in top-level template code  
    {%- import_yaml './defaults.yaml' as defaults %}                                                      
  File "c:\salt\bin\lib\site-packages\salt-3003.3-py3.7.egg\salt\utils\jinja.py", line 198, in get_source 
    raise TemplateNotFound(template)                                                                      
jinja2.exceptions.TemplateNotFound: ./defaults.yaml

Expected behaviour

It should install the package prometheus-windows-exporter using chocolatey.

Attempts to fix the bug

I submitted a PR that seems to fix the problem: #77

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions