saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

[BUG] modules.ebuildpkg.installed does not honor the 'slot' argument when called from state.pkg.installed #58542

Open ijansky opened 4 years ago

ijansky commented 4 years ago

Description The modules.ebuildpkg.installed module function has an extra argument slot that installs the latest available version in the specified slot. According to the documentation it is ignored if pkgs or sources or version arguments are passed to the function. However, when the function is called from the states.pkg.installed state function, the slot argument is ignored, because the states.pkg.installed state function calls the module function with the pkgs argument - even for single package states. See the additional context section for details.

I am not sure whether this is an issue with the implementation of modules.ebuildpkg.installed or states.pkg.installed.

Setup Gentoo box running salt and the following SLS file.

postgresql:
  pkg.installed:
    - name: dev-db/postgresql
    - slot: 10

Steps to Reproduce the behavior The issue can be reproduced by executing the SLS file mentioned above or by running the following command:

sudo salt-call --local --log-level=debug state.single pkg.installed dev-db/postgresql slot=10 refresh=False

Notice that the name argument is set to None, while the pkgs argument is passed in with one item equal to the package name.

[DEBUG   ] Called modules.pkg.install: {'name': None, 'refresh': False, 'pkgs': [{'dev-db/postgresql': None}], 'sources': None, 'kwargs': {'version': None, 'skip_verify': False, 'reinstall': False, 'normalize': True, 'update_holds': False, 'ignore_epoch': None, 'saltenv': 'base', 'allow_updates': False}, 'binhost': None}
...
[INFO    ] Executing command ['emerge', '--ask', 'n', '--quiet', 'dev-db/postgresql'] in directory '/root'

Expected behavior The package should be installed with the desired slot version. In this particular case, the expectations is to install dev-db/postgresql:10.

[INFO    ] Executing command ['emerge', '--ask', 'n', '--quiet', 'dev-db/postgresql:10'] in directory '/root'

Versions Report

salt --versions-report ``` Salt Version: Salt: 3001.1 Dependency Versions: cffi: 1.14.0 cherrypy: Not Installed dateutil: Not Installed docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 2.11.2 libgit2: 1.0.1 M2Crypto: Not Installed Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 1.0.0 mysql-python: Not Installed pycparser: 2.20 pycrypto: 3.9.8 pycryptodome: 3.9.8 pygit2: 1.2.1 Python: 3.8.5 (default, Sep 17 2020, 21:17:31) python-gnupg: Not Installed PyYAML: 5.3.1 PyZMQ: 19.0.1 smmap: Not Installed timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.3.2 System Versions: dist: gentoo 2.7 locale: utf-8 machine: x86_64 release: 5.4.64 system: Linux version: Gentoo 2.7 ```

Additional context

State function packing the name argument into a pkgs array. https://github.com/saltstack/salt/blob/e941aa8fd207bb2addd1caa5ffe26cd9ae966095/salt/states/pkg.py#L1685-L1692

Module function not executing due to pkgs being set. https://github.com/saltstack/salt/blob/e941aa8fd207bb2addd1caa5ffe26cd9ae966095/salt/modules/ebuildpkg.py#L676-L687

welcome[bot] commented 4 years ago

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at core@saltstack.com or reach out directly to the Community Manager, Cassandra Faris via Slack. We’re glad you’ve joined our community and look forward to doing awesome things with you!

danielrobbins commented 3 years ago

This issue has been approved to be fixed in a future release of salt.