salt icon indicating copy to clipboard operation
salt copied to clipboard

pkg.latest seems to be broken

Open gitlerhub opened this issue 10 years ago • 6 comments

Versions: openSuse 13.2 with salt-2015.8.3-223.7.x86_64

I have this sls:

mypackage:
  pkg.latest:
    - name: mypackage
    - refresh: true
    - skip_verify: true

When running

salt-call state.sls mypackage

I get this error:

----------
          ID: mypackage
    Function: pkg.latest
        Name: mypackage
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/site-packages/salt/state.py", line 1594, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1491, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/site-packages/salt/states/pkg.py", line 1449, in latest
                  elif not cur[pkg] \
              KeyError: 'mypackage'
     Started: 01:15:59.350284
    Duration: 1709.687 ms
     Changes:   
----------

I tested a little bit with:

salt-call  pkg.latest_version mypackage

and got:

local:
    ----------

Maybe there others, but one problem is the handling of the status:

 salt-call pkg.info_available  mypackage
local:
    ----------
   mypackage:
        ----------
        arch:
            noarch
        installed:
            True
        installed size:
            819 B
        repository:
            xxx
        status:
            out-of-date (version 1.0.1-1 installed)
        summary:
            scripts
        vendor:
            xxxx
        version:
            1.0.5-1

I found the problem in the zypper.py code

if pkg_info.get('status', '').lower() in ['not installed', 'out-of-date']:

I changed it to

        if re.search('not installed',pkg_info.get('status', '').lower()) or re.search('out-of-date',pkg_info.get('status', '').lower()) or re.search('up-to-date',pkg_info.get('status', '').lower()):

With these changes, running again:

salt-call  pkg.latest_version mypackage

shows the expected result:

local:
    1.0.5-1

gitlerhub avatar Jan 17 '16 00:01 gitlerhub

@gitlerhub - thanks. Feel free to submit a pull request to get this fix in.

ssgward avatar Jan 19 '16 16:01 ssgward

Seems to fail on Centos 6 too. The package is installed, but the state fails nonetheless. Salt version is git develop from tonight (installed with salt-bootstrap, options: -X git develop)

          ID: nodejs
    Function: pkg.latest
      Result: False
     Comment: The following packages failed to update: nodejs
     Started: 00:21:44.219174
    Duration: 2869.235 ms
     Changes:   
              ----------
              nodejs:
                  ----------
                  new:
                      0.10.1-16
                  old:

unicolet avatar Jan 30 '16 12:01 unicolet

If it helps it seems that from current salt unstable rpm for Centos 6 to develop the way salt figures if a package has been installed or not has changed. Was repoquery in stable and unstable, it's rpm -qa in develop.

Let me know if you need more details.

unicolet avatar Jan 30 '16 14:01 unicolet

I've seen pkg.latest fail today while running 2015.5.9 on Fedora 23 and 2015.5.3 on Ubuntu 14.04.

rbjorklin avatar Feb 03 '16 14:02 rbjorklin

Currently watching pkg.latest fail on Centos 7.2

c2d544ca-00f2-11e6-a028-06d4fd72ffe9:
    Salt Version:
               Salt: 2015.8.8.2

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

    System Versions:
               dist: centos 7.2.1511 Core
            machine: x86_64
            release: 3.10.0-327.10.1.el7.x86_64
             system: CentOS Linux 7.2.1511 Core

hartloosli avatar May 18 '16 03:05 hartloosli

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.

stale[bot] avatar May 08 '18 04:05 stale[bot]