I want to keep the latest version of a pip package installed, but every time I run highstate it reports changes.
pip.installed
with upgrade: True
would work like pkg.latest
, doing a check, and then not making a change unless there is an update available.
State run returns changes every time.
python-pip:
pkg.latest
sh:
pip.installed:
- upgrade: True
- require:
- pkg: python-pip
$ sudo salt-call state.sls python
[...]
[INFO ] Package python-requests is already up-to-date.
[INFO ] Completed state [python-requests] at time 15:51:41.279153
[INFO ] Running state [sh] at time 15:51:41.280197
[INFO ] Executing state pip.installed for sh
[INFO ] Executing command '/usr/bin/pip freeze' in directory '/root'
[INFO ] Executing command "/usr/bin/pip install --upgrade 'sh'" in directory '/root'
[INFO ] Executing command '/usr/bin/pip freeze' in directory '/root'
[INFO ] {'sh==1.11': 'Installed'}
[INFO ] Completed state [sh] at time 15:51:52.120153
local:
----------
ID: sh
Function: pip.installed
Result: True
Comment: Package was successfully installed
Started: 15:51:41.280197
Duration: 10839.956 ms
Changes:
----------
sh==1.11:
Installed
Summary
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
$ sudo salt-call state.sls python
[...]
[INFO ] Package python-requests is already up-to-date.
[INFO ] Completed state [python-requests] at time 15:54:31.859171
[INFO ] Running state [sh] at time 15:54:31.859992
[INFO ] Executing state pip.installed for sh
[INFO ] Executing command '/usr/bin/pip freeze' in directory '/root'
[INFO ] Executing command "/usr/bin/pip install --upgrade 'sh'" in directory '/root'
[INFO ] Executing command '/usr/bin/pip freeze' in directory '/root'
[INFO ] {'sh==1.11': 'Installed'}
[INFO ] Completed state [sh] at time 15:54:42.579534
local:
----------
ID: sh
Function: pip.installed
Result: True
Comment: Package was successfully installed
Started: 15:54:31.859992
Duration: 10719.542 ms
Changes:
----------
sh==1.11:
Installed
Summary
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
salt-call --versions-report
Salt: 2014.7.5
Python: 2.7.3 (default, Mar 13 2014, 11:03:55)
Jinja2: 2.6
M2Crypto: 0.21.1
msgpack-python: 0.1.10
msgpack-pure: Not Installed
pycrypto: 2.6
libnacl: Not Installed
PyYAML: 3.10
ioflo: Not Installed
PyZMQ: 13.1.0
RAET: Not Installed
ZMQ: 3.2.3
Mako: 0.7.0
Debian source package: 2014.7.5+ds-1~bpo70+1
$ dpkg -l python-pip
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=======================-================-================-====================================================
ii python-pip 1.1-3 all alternative Python package installer
$ pip --version
pip 1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
@nicholascapo, do you still have this error on 2015.5.0 or later?
Yes
$ salt --versions-report
Salt: 2015.5.0
Python: 2.7.3 (default, Mar 13 2014, 11:03:55)
Jinja2: 2.6
M2Crypto: 0.21.1
msgpack-python: 0.1.10
msgpack-pure: Not Installed
pycrypto: 2.6
libnacl: Not Installed
PyYAML: 3.10
ioflo: Not Installed
PyZMQ: 13.1.0
RAET: Not Installed
ZMQ: 3.2.3
Mako: 0.7.0
Debian source package: 2015.5.0+ds-1~bpo70+1
---
python-pip:
pkg.latest
sh:
pip.installed:
- upgrade: true
- require:
- pkg: python-pip
The output from subsequent runs is the same:
$ sudo salt-call --retcode-passthrough state.sls python
[...]
[INFO ] Package python-pip is already up-to-date.
[INFO ] Completed state [python-pip] at time 22:35:23.447469
[INFO ] Running state [sh] at time 22:35:23.486890
[INFO ] Executing state pip.installed for sh
[INFO ] Executing command '/usr/bin/pip freeze' in directory '/root'
[INFO ] Executing command "/usr/bin/pip install --upgrade 'sh'" in directory '/root'
[INFO ] Executing command '/usr/bin/pip freeze' in directory '/root'
[INFO ] {'sh==1.11': 'Installed'}
[INFO ] Completed state [sh] at time 22:35:24.455039
local:
----------
ID: sh
Function: pip.installed
Result: True
Comment: All packages were successfully installed
Started: 22:35:23.486890
Duration: 968.149 ms
Changes:
----------
sh==1.11:
Installed
Summary
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
@jfindlay Looking at it again, This seems like (partially) reasonable behavior. It really just runs pip
with --upgrade
which is how I would do it on the commandline.
I would be satisfied with a new pip.latest
state, and leave this functionally the same.
If you like, you are welcome to change this into a feature request for pip.latest
.
@nicholascapo, that sounds fine to me, thanks.
+1 for the feature request. I need to keep pip up to date and pip.latest would be just the ticket.
+1 for pip.latest.
pip.latest +1
I'm seeing this too. I don't believe the behaviour is reasonable though. If nothing changed, it shouldn't report a change. Or is there actually something changing that is not made clear? Thanks!
@driskell This could potentially upgrade the dependencies of the package that you are wanting to install by upgrading them. IIRC there was a note on the Pypi/pip readthedocs about the somewhat crazy way to upgrade a single package which is to update other packages first with a no depends and then update the package you actually wanted to update. I'm not sure how Salt passes it through to pip, but I know doing a pip -U install somethign will also get somethingelse that was depended on at its latest version.
@dragon788 Yes not ideal, though I think that is more a pip problem than a salt state problem. The issue I have here is even if nothing is changed by the upgrade, salt state reports a bogus change.
I remember something about a pip bug causing upgrade to always reinstall (which would be a change). But it's not clear from the salt state output that anything was changed and this is bound to be fixed eventually in pip if not already. So salt state should either report no change or report what was changed. Otherwise the status is meaningless and confusing :(
Has there been any movement or workarounds on this?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
This is still an annoyance!
Thank you for updating this issue. It is no longer marked as stale.
@saltstack/team-triage FYI
Most helpful comment
Has there been any movement or workarounds on this?