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

pkg.latest improperly reports failure when latest package is already installed. #35747

Closed
joejulian opened this issue Aug 24, 2016 · 8 comments
Closed
Labels
Bug broken, incorrect, or confusing behavior P3 Priority 3 Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around State-Module
Milestone

Comments

@joejulian
Copy link
Contributor

joejulian commented Aug 24, 2016

Description of Issue/Question

With multiple packages, pkg.latest fails if the latest packages are already installed:

# salt-call state.single pkg.latest name=lots_wife 'pkgs=[git,vim]'         
[ERROR   ] The following targeted packages failed to update. See debug log for details: (git, vim).
local:
----------
          ID: lots_wife
    Function: pkg.latest
      Result: False
     Comment: The following targeted packages failed to update. See debug log for details: (git, vim).
     Started: 12:20:03.014792
    Duration: 544.661 ms
     Changes:   

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
# pacman -Q git vim
git 2.9.3-1
vim 7.4.2143-1

# pacman -S --needed git vim
warning: git-2.9.3-1 is up to date -- skipping
warning: vim-7.4.2143-1 is up to date -- skipping
 there is nothing to do

Fails in Centos 7 also.

Versions Report

Salt Version:
           Salt: 2016.3.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: 1.5.5
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: 1.4.5
       M2Crypto: 0.24.0
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.7
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.12 (default, Jun 28 2016, 08:31:05)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: 0.6.5
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.4.1
            ZMQ: 4.1.5

System Versions:
           dist:   
        machine: x86_64
        release: 4.7.0-1-ARCH
         system: Linux
        version: Not Installed
Salt Version:
           Salt: 2016.3.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.7
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.5 (default, Nov 20 2015, 02:00:19)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.2.1511 Core
        machine: x86_64
        release: 4.7.0-1-ARCH
         system: Linux
        version: CentOS Linux 7.2.1511 Core
@Ch3LL
Copy link
Contributor

Ch3LL commented Aug 25, 2016

@joejulian i'm having a hard time replicating this:

sls file:

mypkgs:
  pkg.latest:
    - pkgs:
      - docker-engine
      - vivaldi-snapshot
local:
----------
          ID: mypkgs
    Function: pkg.latest
      Result: True
     Comment: The following packages were successfully installed/upgraded: vivaldi-snapshot The following packages were already up-to-date: docker-engine
     Started: 12:07:33.031168
    Duration: 86660.927 ms
     Changes:   
              ----------
              vivaldi-snapshot:
                  ----------
                  new:
                      1.3.551.37-1
                  old:
                      1.3.551.28-1

Summary for local
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1

It does seem like in your PR that you note you are working on a fix so if you see where the issue is thats great. I'll label as a bug and it might be a system side issue, because it seems to be workign for me on 2016.3.2.

@Ch3LL Ch3LL added State-Module Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P3 Priority 3 Platform Relates to OS, containers, platform-based utilities like FS, system based apps labels Aug 25, 2016
@Ch3LL Ch3LL added this to the Approved milestone Aug 25, 2016
@joejulian
Copy link
Contributor Author

@Ch3LL Now run it again. You successfully upgraded a package. Upgrading no packages seems to be where the bug is.

joejulian added a commit to joejulian/salt that referenced this issue Aug 25, 2016
Test to verify that pkg.latest can, when using a pkgs list, recognize
packages that are already installed, and can install packages that are
not.

Test for issue saltstack#35747
joejulian added a commit to joejulian/salt that referenced this issue Aug 25, 2016
Test to verify that pkg.latest can, when using a pkgs list, recognize
packages that are already installed, and can install packages that are
not.

Test for issue saltstack#35747
joejulian added a commit to joejulian/salt that referenced this issue Aug 25, 2016
I inverted the logic for determining targets to more logically represent
the process we're trying to follow. This allows the tests to pass where
they both previously failed.

Fixes saltstack#35747
joejulian added a commit to joejulian/salt that referenced this issue Aug 29, 2016
When installing multiple packages, pkg.latest was failing on arch and
centos if the packages were already installed. This inverts the logic
for determining if a package needs updated to make it simpler.

This uncovered a flaw in the pkg.latest_version module for yum where it
was not returning versions if a package was installed.

Fixes saltstack#35747
@terminalmage
Copy link
Contributor

This is caused by incorrect behavior of the pkg.latest_version function. It is supposed to return an empty string for packages which do not have an upgrade available (or for which there is no match in the package database).

This is fixed in #35880.

@joejulian
Copy link
Contributor Author

I'll just use a for loop.

@terminalmage
Copy link
Contributor

Uh, for what?

@joejulian
Copy link
Contributor Author

{% for pkg in pkgs %}...

@terminalmage
Copy link
Contributor

Yeah, we cleared it up via email. Unfortunately requisites check for either the name declaration or the ID declaration. It may be possible to alter the requisite system to pay attention to the sources or pkgs param when the requisite type is pkg, though.

@rthille
Copy link

rthille commented May 15, 2023

This is caused by incorrect behavior of the pkg.latest_version function. It is supposed to return an empty string for packages which do not have an upgrade available (or for which there is no match in the package database).

This is fixed in #35880.

This seems to be an issue with mac_brew_pkg's implementation as well: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.mac_brew_pkg.html#salt.modules.mac_brew_pkg.latest_version

bash-3.2$ salt-ssh -l info 'ci-example' state.sls_id latest_packages ci/packages
[INFO    ] Loading Saltfile from '/Users/example/mac-example/Saltfile'
[INFO    ] Caching directory '_modules/' for environment 'base'
[INFO    ] Caching directory '_states/' for environment 'base'
[INFO    ] Caching directory '_grains/' for environment 'base'
[INFO    ] Caching directory '_renderers/' for environment 'base'
[INFO    ] Caching directory '_returners/' for environment 'base'
[INFO    ] Caching directory '_output/' for environment 'base'
[INFO    ] Caching directory '_utils/' for environment 'base'
ci-example:
----------
          ID: latest_packages
    Function: pkg.latest
      Result: False
     Comment: Package ruby-build failed to update.
     Started: 14:59:14.391136
    Duration: 6462.049 ms
     Changes:   

Summary for ci-example
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   6.462 s
bash-3.2$ salt-ssh -l info 'ci*-example' pkg.latest_version ruby-build
[INFO    ] Loading Saltfile from '/Users/example/mac-example/Saltfile'
ci-example
    20230512
bash-3.2$ 

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 P3 Priority 3 Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around State-Module
Projects
None yet
Development

No branches or pull requests

4 participants