saltstack-formulas / salt-formula

Yes, Salt can Salt itself!
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
198 stars 421 forks source link

[BUG] Unable to manage file: Jinja error: 'NoneType' object has no attribute 'done' #547

Closed darkpixel closed 1 year ago

darkpixel commented 1 year ago

I recently did a git pull to update my salt-formula to the latest version. Windows minions (are running Salt 3005.1) are throwing this error when applying the salt.minion state:

local:
----------
          ID: salt-minion
    Function: file.recurse
        Name: C:\salt\conf\minion.d
      Result: False
     Comment: #### C:\salt\conf\minion.d\f_defaults.conf ####
              Unable to manage file: Jinja error: 'NoneType' object has no attribute 'done'
              Traceback (most recent call last):
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\utils\templates.py", line 471, in render_jinja_tmpl
                  output = template.render(**decoded_context)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\jinja2\environment.py", line 1301, in render
                  self.environment.handle_exception()
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\jinja2\environment.py", line 936, in handle_exception
                  raise rewrite_traceback_stack(source=source)
                File "<template>", line 18, in top-level template code
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\utils\jinja.py", line 185, in get_source
                  self.check_cache(_template)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\utils\jinja.py", line 138, in check_cache
                  ret = self.cache_file(template)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\utils\jinja.py", line 131, in cache_file
                  return fcl.get_file(saltpath, "", True, self.saltenv)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\fileclient.py", line 1173, in get_file
                  hash_server = self.hash_file(path, saltenv)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\fileclient.py", line 1407, in hash_file
                  return self.__hash_and_stat_file(path, saltenv)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\fileclient.py", line 1399, in __hash_and_stat_file
                  return self.channel.send(load)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\utils\asynchronous.py", line 125, in wrap
                  raise exc_info[1].with_traceback(exc_info[2])
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\utils\asynchronous.py", line 131, in _target
                  result = io_loop.run_sync(lambda: getattr(self.obj, key)(*args, **kwargs))
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\ext\tornado\ioloop.py", line 457, in run_sync
                  if not future_cell[0].done():
              AttributeError: 'NoneType' object has no attribute 'done'

              ; line 18

              ---
              [...]
              {{ configname }}: {{ cfg_salt[configname]|json }}
              {%- else -%}
              #{{ configname }}: {{ default_value|json }}
              {%- endif -%}
              {%- endmacro -%}
              {%- from 'salt/formulas.jinja' import file_roots, formulas with context -%}    <======================

              ##### Primary configuration settings #####
              ##########################################
              # This configuration file is used to manage the behavior of the Salt Minion.
              # With the exception of the location of the Salt Master Server, values that are
              [...]
              ---
     Started: 19:31:44.552838
    Duration: 4017.866 ms
     Changes:

Pillar from a minion throwing the error:

--redacted--:
    ----------
    clean_config_d_dir:
        True
    install_packages:
        False
    minion:
        ----------
        color:
            True
        master:
            --redacted--
        master_alive_interval:
            30
        mine_interval:
            5
        minion_id_caching:
            False
        ping_interval:
            1
        retry_dns:
            60
        state_output:
            changes
        use_superseded:
            - module.run
    minion_remove_config:
        True
Foorack commented 1 year ago

Able to reproduce on Linux. But this seems to be a general Salt problem, and not related to this repo.


 \- global
    \- ad
      |- init.sls
      |- map.sls
      \- test.sls 

map.jinja

{% set ad = ({
    "domain": "example.com"
})%}

init.sls

{% from tpldir ~ "/map.jinja" import ad with context %}
{% do salt.log.error(ad.domain) %}   <=== WORKS

include:
  - .test

test.sls

{% from tpldir ~ "/map.jinja" import ad with context %}    <== does NOT work
{% do salt.log.error(ad.domain) %}

When importing in init.sls it works, but when importing in a different file I get the same same "NoneType has no attr 'done' error as OP.

darkpixel commented 1 year ago

You're right @Foorack. Looks like it's being tracked here: https://github.com/saltstack/salt/issues/64111

I'm going to close this out because it appears to be a bug with Jinja template rendering, not with salt-formula.