saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.18k stars 5.48k forks source link

saltutil.sync_utils does not work for the salt.utils.templates module? #51719

Closed arizvisa closed 5 years ago

arizvisa commented 5 years ago

Description of Issue/Question

I wrote a PR (#51718) to fix the support of the Cheetah engine in salt.utils.templates, and I'm trying to synchronize my fix to each minion via saltutil.sync_all or saltutil.sync_utils (until you guys merge it or whatever). However, for some reason salt-minion is still picking up the path via salt.utils.templates (in site-packages/salt) instead of honoring the module in the extmods cache. Is this unsupported for certain modules, or is it just a version issue on my end?

Setup

Write templates.py to _utils under your salt base environment so that when you call saltutil.sync_utils, it'll cache it under extmods. Just to be sure, you can rm the salt/utils/templates.py file from your site-packages on the target minion. This should normally be okay because salt-minion should pick up the templates.py module that is cached in extmods.

Steps to Reproduce Issue

Run salt $target saltutil.sync_utils to confirm the templates.py module gets synchronized. However, note that salt-minion will still use the old salt.utils.templates module, or complain that it is unable to locate the module via an ImportError.

Versions Report

Salt Version:
           Salt: 2018.3.3

Dependency Versions:
           cffi: 1.10.0
       cherrypy: 10.2.1
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: 2.0.5
      gitpython: 2.1.3
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: 1.6.1
       M2Crypto: Not Installed
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: 2.17
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.3
           RAET: Not Installed
          smmap: 2.0.5
        timelib: 0.2.4
        Tornado: 4.5.1
            ZMQ: 4.1.6

System Versions:
           dist:
         locale: cp1252
        machine: AMD64
        release: 8
         system: Windows
        version: 8 6.2.9200 SP0 Multiprocessor Free
dwoz commented 5 years ago

@arizvisa overriding utils modules via the extension_modules setting can be hit or miss depending on how the utils module is imported where it is being used.

arizvisa commented 5 years ago

gotcha, in that case the salt.utils.template is not using the loader, and so it's hard to hotpatch #51718.

arizvisa commented 5 years ago

but i have a workaround. if this isn't something you guys plan on changing, we can close this issue.

arizvisa commented 5 years ago

Closing this issue as it appears that it's not something you guys plan on changing.