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

state pkg.installed not working on FreeBSD when version is specified #55630

Open
angeloudy opened this issue Dec 13, 2019 · 15 comments
Open

state pkg.installed not working on FreeBSD when version is specified #55630

angeloudy opened this issue Dec 13, 2019 · 15 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE FreeBSD severity-high 2nd top severity, seen by most users, causes major problems ZD The issue is related to a Zendesk customer support ticket.
Milestone

Comments

@angeloudy
Copy link
Contributor

I have the following state file.

mariadb_pkg:
  pkg.installed:
    - name: mariadb103-server
    - version: {{ salt['pillar.get']('mariadb:version', default_db_version) }}

It worked fine for two year until I recently upgraded salt to 2019.2.2

When I run it in debug mode, I got the following message:

16:02:31,455 [DEBUG   ] Current version ({'origin': 'databases/mariadb103-server', 'version': ['10.3.20']}) did not match desired version specification (10.3.20), adding to installation targets

It seems that salt was trying to compare a dict with str and decided that it didn't match.

Versions Report

Salt Version:
           Salt: 2019.2.2

Dependency Versions:
           cffi: 1.13.2
       cherrypy: Not Installed
       dateutil: 2.8.0
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10.1
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: 1.4.2.post1
      pycparser: 2.19
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.9 (default, Nov 12 2019, 23:28:35)
   python-gnupg: Not Installed
         PyYAML: 5.1
          PyZMQ: 18.1.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.1

System Versions:
           dist:
         locale: UTF-8
        machine: amd64
        release: 12.1-RELEASE
         system: FreeBSD
        version: Not Installed
@waynew
Copy link
Contributor

waynew commented Dec 18, 2019

@angeloudy what version were you previously on?

@waynew waynew moved this from Needs triage to Blocked in [Test] Triage Dec 18, 2019
@angeloudy
Copy link
Contributor Author

@waynew
My previous version is 2018.3.3

@asomers
Copy link
Contributor

asomers commented Dec 26, 2019

This issue is addressed by PR #54074 . However, I don't think that the currently posted PR contains the best possible solution.

@waynew
Copy link
Contributor

waynew commented Jan 7, 2020

I'm working on verifying this, still getting Salt up & running on a BSD box.

@waynew waynew added Confirmed Salt engineer has confirmed bug/feature - often including a MCVE Bug broken, incorrect, or confusing behavior and removed needs-triage labels Jan 9, 2020
@waynew
Copy link
Contributor

waynew commented Jan 9, 2020

I was able to reproduce this, and discovered the actual cause (discussed at #54074). There's a bit more digging to decide on the appropriate fix, but for a workaround, one could patch states/pkg.py removing these two lines:

https://github.com/saltstack/salt/blob/4fed7e0/salt/states/pkg.py#L1844-L1845

I'm not sure why that was introduced a very long time ago, but it appears that the pkgng.py state ends out doing the wrong thing in this case.

@waynew waynew added the FreeBSD label Jan 9, 2020
@waynew waynew changed the title state pkg.installed not working when version is specified state pkg.installed not working on FreeBSD when version is specified Jan 9, 2020
@waynew waynew removed their assignment Jan 9, 2020
@waynew waynew moved this from Blocked to High priority in [Test] Triage Jan 9, 2020
@waynew waynew added this to the Approved milestone Jan 9, 2020
@asomers
Copy link
Contributor

asomers commented Jan 9, 2020

I think I know why that change was introduced. Every FreeBSD port has an "origin", which is basically the category of the port. Categories include stuff like "graphics", "devel", "astro", etc. Though rare, two ports can have the same name but different origins. Examples include devel/atlas and math/atlas or multimedia/dragon and devel/dragon. When installing such a port through pkg(8), you must specify the origin in order to unambiguously identify the correct package. So I would say we cannot simply remove the two lines that set with_origin.

@waynew
Copy link
Contributor

waynew commented Jan 10, 2020

@asomers that makes a lot of sense.

I wonder - would it make sense to allow passing with_origin in? With a default of True on FreeBSD?

Another thought is that if we can unambiguously return an installed version there's really no reason for us to require a with_origin, right?

@asomers
Copy link
Contributor

asomers commented Jan 10, 2020

My idea is to replace list_pkgs's with_origin flag with a verbose flag, that would be recognized by all pkg implementations. Without verbose set, the output would look like it does today without with_origin set. But with verbose, the output would look like it does today when with_origin is set, for all package implementations. But the origin field would only be present where it makes sense. So For FreeBSD it might return something like {'dragon': {'version': '1.0.0', 'origin': 'devel'}} but on Debian it would exclude origin, like this: {'dragon': {'version': '1.0.0'}}. The nice thing about this approach is that it would minimize inconsistencies between different OSes.

@fzipi
Copy link
Contributor

fzipi commented Mar 20, 2020

Is there an expected timeline for this?

@asomers
Copy link
Contributor

asomers commented Mar 20, 2020

@fzipi I don't have any time allocated for it right now.

@whytewolf whytewolf added the ZD The issue is related to a Zendesk customer support ticket. label Mar 20, 2020
@whytewolf
Copy link
Contributor

zd-4827

@whytewolf
Copy link
Contributor

So the workaround in #55630 (comment) does work, however, it introduces other issues. So it is correct that is not a valid fix.

Issue created by the workaround.

----------
ID: freebsd_packages_installed_java/openjdk7
Function: pkg.installed
Name: java/openjdk7
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/salt/state.py", line 1933, in call
**cdata['kwargs'])
File "/usr/local/lib/python2.7/site-packages/salt/loader.py", line 1951, in wrapper
return f(*args, **kwargs)
File "/var/cache/salt/minion/extmods/states/pkg.py", line 1787, in installed
new_caps=new_caps)
File "/var/cache/salt/minion/extmods/states/pkg.py", line 857, in _verify_install
cver = [k for k, v in six.iteritems(new_pkgs) if v['origin'] == pkgname]
TypeError: list indices must be integers, not unicode
Started: 12:09:51.413210
Duration: 58826.337 ms
Changes:
Name: apr - Function: pkg.installed - Result: Clean Started: - 12:10:50.244422 Duration: 40.43 ms

@sagetherage sagetherage added this to Considering in Magnesium May 21, 2020
@sagetherage sagetherage added the Magnesium Mg release after Na prior to Al label Jul 6, 2020
@sagetherage sagetherage added this to the Aluminium milestone Oct 7, 2020
@sagetherage sagetherage added this to Planning in Aluminium Oct 20, 2020
@s0undt3ch s0undt3ch removed their assignment Feb 9, 2021
@s0undt3ch
Copy link
Member

@krionbsd is looking into this one

@sagetherage sagetherage added the Needs-Testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases label Feb 19, 2021
@sagetherage
Copy link
Contributor

this still needs a test case written, I removed Aluminium label from the PR, but will leave it on the issue to see if we can find time to write tests next week. If not, this will likely be de-scoped from the Aluminium release.

@sagetherage sagetherage modified the milestones: Aluminium, Approved Feb 24, 2021
@sagetherage sagetherage added Silicon v3004.0 Release code name and removed Aluminium Release Post Mg and Pre Si labels Feb 24, 2021
@sagetherage sagetherage modified the milestones: Approved, Silicon Feb 24, 2021
@sagetherage sagetherage added the P1 Priority 1 label May 18, 2021
@sagetherage sagetherage removed the Silicon v3004.0 Release code name label Aug 19, 2021
@sagetherage sagetherage modified the milestones: Silicon, Approved Aug 19, 2021
@sagetherage sagetherage removed Needs-Testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases P1 Priority 1 labels Aug 19, 2021
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 Confirmed Salt engineer has confirmed bug/feature - often including a MCVE FreeBSD severity-high 2nd top severity, seen by most users, causes major problems ZD The issue is related to a Zendesk customer support ticket.
Projects
No open projects
[Test] Triage
  
High priority
Development

Successfully merging a pull request may close this issue.

8 participants