-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
bugbroken, incorrect, or confusing behaviorbroken, incorrect, or confusing behavior
Milestone
Description
Description
When using the ~= version specifier with pip.installed errors are logged. The state does run successfully, though always thinks there have been changes.
Setup
- on-prem machine
- VM (Virtualbox, KVM, etc. please specify)
- VM running on a cloud service, please be explicit and add details
- container (Kubernetes, Docker, containerd, etc. please specify)
- or a combination, please be explicit
- jails if it is FreeBSD
- classic packaging
- onedir packaging
- used bootstrap to install
Steps to Reproduce the behavior
# salt-call --local state.single pip.installed name='elasticsearch ~= 7.17.6' -linfo
[INFO] Loading fresh modules for state activity
[INFO] Running state [elasticsearch ~= 7.17.6] at time 15:47:39.466748
[INFO] Executing state pip.installed for [elasticsearch ~= 7.17.6]
[INFO] Executing command /opt/saltstack/salt/salt-pip in directory '/root'
[INFO] Executing command /opt/saltstack/salt/salt-pip in directory '/root'
[ERROR] Invalid operator '~=' for version comparison
[INFO] Executing command /opt/saltstack/salt/salt-pip in directory '/root'
[INFO] Executing command /opt/saltstack/salt/salt-pip in directory '/root'
[INFO] Executing command /opt/saltstack/salt/salt-pip in directory '/root'
[INFO] {'elasticsearch==7.17.12': 'Installed'}
[INFO] Loading fresh modules for state activity
[INFO] Completed state [elasticsearch ~= 7.17.6] at time 15:47:43.298461 (duration_in_ms=3831.713)
local:
Name: elasticsearch ~= 7.17.6 - Function: pip.installed - Result: Changed - Started: 15:47:39.466748 - Duration: 3831.713 ms
Summary for local
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 3.832 s
Expected behavior
All Python package version specifiers should be handled correctly, with no errors logged.
Versions Report
salt-call --versions
Salt Version:
Salt: 3006.9
Python Version:
Python: 3.10.14 (main, Jun 26 2024, 11:44:37) [GCC 11.2.0]
Dependency Versions:
cffi: 1.17.1
cherrypy: 18.6.1
cryptography: 42.0.5
dateutil: 2.8.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.4
libgit2: 1.7.1
looseversion: 1.0.2
M2Crypto: 0.38.0
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: 1.13.3
python-gnupg: 0.4.8
PyYAML: 6.0.1
PyZMQ: 23.2.0
relenv: 0.17.0
smmap: Not Installed
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: ubuntu 24.04.1 noble
locale: utf-8
machine: x86_64
release: 6.8.0-47-generic
system: Linux
version: Ubuntu 24.04.1 nobleAdditional information
There are similar issues with other specifiers, for example:
[ERROR] Comparison of package versions "7.17.12" and "7.17.*" failed: Invalid version: '7.17.*'
Traceback (most recent call last):
File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/pip_state.py", line 365, in _pep440_version_cmp
if pkg_resources.parse_version(pkg1) < pkg_resources.parse_version(pkg2):
File "/opt/saltstack/salt/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/version.py", line 198, in __init__
raise InvalidVersion(f"Invalid version: '{version}'")
pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: '7.17.*'
Metadata
Metadata
Assignees
Labels
bugbroken, incorrect, or confusing behaviorbroken, incorrect, or confusing behavior