Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 3006.8 DeprecationWarning salt.utils.psutil_compat #66467

Open
2 tasks done
RolandRosenfeld opened this issue May 6, 2024 · 6 comments
Open
2 tasks done

[BUG] 3006.8 DeprecationWarning salt.utils.psutil_compat #66467

RolandRosenfeld opened this issue May 6, 2024 · 6 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@RolandRosenfeld
Copy link

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.8

Python 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`.
@RolandRosenfeld RolandRosenfeld added Bug broken, incorrect, or confusing behavior needs-triage labels May 6, 2024
Copy link

welcome bot commented May 6, 2024

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!

@RolandRosenfeld
Copy link
Author

I dived a little deeper into this issue and found out, that psutil_compat isn'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/utils is executed/compiled on state.apply also files which aren't imported or used.
I did a little test: copied psutil_compat.py to test.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 from test.py. I also noticed, that __pycache__/test.cpython-310.pyc was created.

So it seems that we should remove psutil_compat.py from the salt-common package (or make sure that is isn't executed unintentionally), since the depecation warning on salt-call state.apply or in the log (when state.apply is executed from master) is quite annoying.

@tjyang
Copy link
Contributor

tjyang commented May 6, 2024

@RolandRosenfeld , I saw this error message also. for thanks the detail analysis. Hope salt core dev team can acknowledge and fix it in the next release. (this was not a "hope" but was expected before Broadcomm's purchase).

@RolandRosenfeld
Copy link
Author

As a workaround the following gets rid of the warning. Hopefully I don't have to extend the version guard:

{% if grains.saltversion == "3006.8" %}
/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/psutil_compat.py:
  file.absent

/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/psutil_compat.cpython-310.pyc:
  file.absent
{% endif %}

@tjyang
Copy link
Contributor

tjyang commented May 6, 2024

@RolandRosenfeld
Thanks for this salt tip. I will add this into my salt-minion restart formula, which also have another file removal for version 3007 minions.

@slinrain
Copy link

As I investigated this warning shows in all states where using state.pkg (pkg.installed, pkg.purged, pkg.latest etc). In other states doesn't reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

3 participants