saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.1k stars 5.47k forks source link

rpm fails to detect already installed packages #41234

Closed non7top closed 7 years ago

non7top commented 7 years ago

Description of Issue/Question

# salt   --force-color 's0.*' state.sls baseconfig.test3 saltenv=dev
s0.example.com:
----------
          ID: sudo
    Function: pkg.latest
      Result: False
     Comment: Package sudo failed to update.
     Started: 18:26:15.076519
    Duration: 6344.674 ms
     Changes:

Summary for s0.example.com
[trace_log.txt](https://github.com/saltstack/salt/files/999505/trace_log.txt)
[trace_log.txt](https://github.com/saltstack/salt/files/999506/trace_log.txt)

------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   6.345 s
ERROR: Minions returned with non-zero exit code

# salt 's0.*' test.versions_report
s0.example.com:
    Salt Version:
               Salt: 2016.11.4

    Dependency Versions:
               cffi: Not Installed
           cherrypy: Not Installed
           dateutil: Not Installed
          docker-py: Not Installed
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
             Jinja2: 2.8.1
            libgit2: Not Installed
            libnacl: Not Installed
           M2Crypto: 0.20.2
               Mako: Not Installed
       msgpack-pure: Not Installed
     msgpack-python: 0.4.6
       mysql-python: Not Installed
          pycparser: Not Installed
           pycrypto: 2.6.1
       pycryptodome: 3.4.3
             pygit2: Not Installed
             Python: 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
       python-gnupg: Not Installed
             PyYAML: 3.11
              PyZMQ: 14.5.0
               RAET: Not Installed
              smmap: Not Installed
            timelib: Not Installed
            Tornado: 4.2.1
                ZMQ: 4.0.5

    System Versions:
               dist: centos 6.9 Final
            machine: x86_64
            release: 2.6.32-042stab123.1
             system: Linux
            version: CentOS 6.9 Final

# cat test3.sls
sudo:
  pkg:
    - latest

Trace log attached.

non7top commented 7 years ago

trace_log.txt

gtmanfred commented 7 years ago

I am unable to replicate this error.

[root@salt ~]# cat /srv/salt/test.sls
sudo:
  pkg:
    - latest
[root@salt ~]# rpm -q sudo
package sudo is not installed
[root@salt ~]# salt-call --local state.apply test
local:
----------
          ID: sudo
    Function: pkg.latest
      Result: True
     Comment: The following packages were successfully installed/upgraded: sudo
     Started: 16:06:19.446604
    Duration: 7279.253 ms
     Changes:
              ----------
              sudo:
                  ----------
                  new:
                      1.8.6p3-27.el6
                  old:

Summary for local
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   7.279 s
[root@salt ~]# salt-call --local state.apply test
local:
----------
          ID: sudo
    Function: pkg.latest
      Result: True
     Comment: Package sudo is already up-to-date
     Started: 16:06:30.231881
    Duration: 3836.558 ms
     Changes:

Summary for local
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time:   3.837 s

Can you run the commands that the yum module is running, and see if you get the same results as the yum module on your system?

Thanks, Daniel

non7top commented 7 years ago

I was able to track this down to option showdupesfromrepos=1, which breaks detection of available updates. This code appears to have changed since version 2015, where I had no issues. Issues started after I updated to 2016.11

# showdupesfromrepos=0
s0 ~ # yum --quiet list available sudo
Error: No matching Packages to list

# showdupesfromrepos=1
s0 ~ # yum --quiet list available sudo
Available Packages
sudo.x86_64                                                             1.8.6p3-27.el6                                                              base

s0 ~ # yum -y install sudo
Loaded plugins: fastestmirror, priorities
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirror.corbina.net
 * epel: fedora-mirror01.rbc.ru
 * extras: mirror.corbina.net
 * updates: mirror.corbina.net
Package sudo-1.8.6p3-27.el6.x86_64 already installed and latest version
Nothing to do

# rpm -qa --queryformat '%{NAME}_|-%{EPOCH}_|-%{VERSION}_|-%{RELEASE}_|-%{ARCH}_|-(none)\n'|grep sudo
sudo_|-(none)_|-1.8.6p3_|-27.el6_|-x86_64_|-(none)
non7top commented 7 years ago

salt-2015.5.11-1.el6.noarch - not affected 2015.8.13-1.el6 - affected

gtmanfred commented 7 years ago

Yup, so it looks like the problem is that showdups is the problem. I am able to replicate this now.

I would say that the fix is to remove that setting for now until we can have a closer look.

@terminalmage you will want to see this.

I have created the docker container gtmanfred/issues:41234 to illustrate this issue.

$ docker run -ti --rm gtmanfred/issues:41234 salt-call state.apply test
[ERROR   ] Package sudo failed to update.
local:
----------
          ID: sudo
    Function: pkg.latest
      Result: False
     Comment: Package sudo failed to update.
     Started: 20:13:38.096000
    Duration: 4839.494 ms
     Changes:

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   4.839 s

Thanks for reporting this. Daniel

terminalmage commented 7 years ago

Fixed by https://github.com/saltstack/salt/pull/41265.