[BUG] modules.ebuildpkg.installed does not honor the 'slot' argument when called from state.pkg.installed
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced state-packing code in salt/states/pkg.py around lines 1685-1692 and the slot-handling logic in salt/modules/ebuildpkg.py around lines 676-687. Reproduce the issue with the supplied state.single command on Gentoo, then trace how a single package and slot reach the module. Done means the state honors slot=10 and invokes emerge with dev-db/postgresql:10, with coverage for the affected path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100