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.19k stars 5.48k forks source link

[BUG] Utilities are not updated #66354

Open IvanShokin opened 7 months ago

IvanShokin commented 7 months ago

Description Subfolders and classes in utils are not updated if multiprocessing is disabled.

Setup

  1. Minion configuration: multiprocessing: False
  2. Add an example with an OOP style from the documentation to the utilities: https://docs.saltproject.io/en/latest/topics/utils/index.html#utility-modules-code-reuse-in-custom-modules
  3. Change the behavior of the class
  4. Calling saltutil.sync_all on the master
  5. Re-execute the module

Expected behavior Utilities are being updated.

Versions Report

salt --versions-report Salt Version: Salt: 3006.7 Python Version: Python: 3.9.16 (main, Feb 21 2023, 09:46:05) Dependency Versions: cffi: 1.15.1 cherrypy: unknown dateutil: 2.8.2 docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 3.1.3 libgit2: 1.5.0 looseversion: 1.3.0 M2Crypto: Not Installed Mako: 1.2.4 msgpack: 1.0.8 msgpack-pure: Not Installed mysql-python: Not Installed packaging: 24.0 pycparser: 2.21 pycrypto: 2.6.1 pycryptodome: 3.20.0 pygit2: 1.11.1 python-gnupg: 0.5.0 PyYAML: 6.0.1 PyZMQ: 25.1.2 relenv: Not Installed smmap: 5.0.0 timelib: 0.2.4 Tornado: 4.5.3 ZMQ: 4.3.4

Additional context The same situation is with the nested structure in utilities.

welcome[bot] commented 7 months ago

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

IvanShokin commented 7 months ago

I suspect the problem is that the utilities are imported into memory and are not updated after calling sync_all. When using importlib.reload, the python module is updated. Is there an API for forcing utilities to be reloaded into memory?