salt: [BUG] 3006.8 DeprecationWarning salt.utils.psutil_compat
Description
I use salt-minion on Debian 12 (bookworm) from
https://repo.saltproject.io/salt/py3/debian/12/amd64/3006 bookworm main
repository.
Since upgrading from 3006.7 to 3006.8
salt-call state.apply test=true
reports the following derecation warning on every call:
/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/psutil_compat.py:16: DeprecationWarning: Please stop importing 'salt.utils.psutil_compat' and instead import 'psutil' directly as there's no longer a need for a compatability layer. The 'salt.utils.psutil_compat' will go away on Salt 3008.0 (Argon).
salt.utils.versions.warn_until(
Since I use the onedir install, which bundles all python modules in salt-common package, I’d expect that this warning does not appear but is fixed.
I observe this issue on all my Debian 12 servers after the upgrade from 3006.7 to 3006.8.
Setup
- VM (Virtualbox, KVM, etc. please specify)
- onedir packaging
Steps to Reproduce the behavior
Upgrade from 3006.7 to 3006.8.
salt-call state.apply test=true
(adding any state name results in the same warning)
A remote salt myhost state.apply test=true call writes the same message to the journal of salt-minion.
Expected behavior No deprecation warnings on console or log if I use only bundled SaltStack 3006.8 software.
Versions Report
salt --versions-report
```yaml Salt Version: Salt: 3006.8Python Version: Python: 3.10.14 (main, Apr 3 2024, 21:30:09) [GCC 11.2.0]
Dependency Versions: cffi: 1.14.6 cherrypy: 18.6.1 dateutil: 2.8.1 docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 3.1.3 libgit2: Not Installed looseversion: 1.0.2 M2Crypto: Not Installed Mako: Not Installed msgpack: 1.0.2 msgpack-pure: Not Installed mysql-python: Not Installed packaging: 22.0 pycparser: 2.21 pycrypto: Not Installed pycryptodome: 3.19.1 pygit2: Not Installed python-gnupg: 0.4.8 PyYAML: 6.0.1 PyZMQ: 23.2.0 relenv: 0.16.0 smmap: Not Installed timelib: 0.2.4 Tornado: 4.5.3 ZMQ: 4.3.4
System Versions: dist: debian 12 bookworm locale: utf-8 machine: x86_64 release: 6.1.0-20-amd64 system: Linux version: Debian GNU/Linux 12 bookworm
</details>
Server and minion are identical except that server has `cherrypy: unknown`.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (8 by maintainers)
As a workaround the following gets rid of the warning. Hopefully I don’t have to extend the version guard:
@dmurphy18 My understanding of a deprecation warning is, that there is a TODO for the developers to get rid of the deprecated code. Since it is still there in 3006.8, I created this ticket to make sure that it isn’t overseen by the developers.
Except this, for me as a user it is quite annoying to get this warning on every “salt-call state.apply” on STDERR. It breaks one of my scripts that tells me that there is a state change pending on this server, so I had to write a workaround. From my point of view a deprecation warning should never pop up to a user of a stable release, but being solved (by removing the call of the deprecated function) before the release to stable.
The above ticket is even more wired, since the deprecated stuff isn’t really used but its pure existence in the directory resulted in the (annoying) warning, so removing the (unused) file solves the issue (why not do so in the next point release?).
I think that the issue should be closed when the warning no longer pops up…
@RolandRosenfeld @matt-work2023 Deprecation Warnings are normal practice for Salt, and vary depending on what is being deprecated. Please consider closing this issue, as the deprecation warning will be removed, generally Salt has deprecation warning for items which will be removed in the next major version of Salt that will be released, see https://docs.saltproject.io/en/latest/topics/development/deprecations.html and release notes for 3007.0 (search for Deprecation) as an example https://docs.saltproject.io/en/latest/topics/releases/3007.0.html
I dived a little deeper into this issue and found out, that
psutil_compatisn’t imported or used at any point in salt. But the file is still excecuted. The problem seems to be, that every python file in/opt/saltstack/salt/lib/python3.10/site-packages/salt/utilsis executed/compiled onstate.applyalso files which aren’t imported or used. I did a little test: copiedpsutil_compat.pytotest.py(in the same directory) and modified the deprecation warning a little. As a result the next ‘state.apply’ showed my two deprecation warnings, one from ‘psutil_compat.py’ and the other fromtest.py. I also noticed, that__pycache__/test.cpython-310.pycwas created.So it seems that we should remove
psutil_compat.pyfrom thesalt-commonpackage (or make sure that is isn’t executed unintentionally), since the depecation warning onsalt-call state.applyor in the log (whenstate.applyis executed from master) is quite annoying.