[BUG] `pkg.installed` state with `dnf` should mark the package as 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
A clear and concise description of what the bug is.
On RHEL-8-based OS, using pkg.installed should mark the package as "installed by user" so that it do not get removed by dependencies.
Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)
Just a simple RockyLinux 8.6 OpenStack VM.
$ cat /etc/centos-release
Rocky Linux release 8.6 (Green Obsidian)
$ uname -a
Linux test-salt-dnf-dependency.novalocal 4.18.0-372.19.1.el8_6.x86_64 #1 SMP Tue Aug 2 16:19:42 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Steps to Reproduce the behavior
(Include debug logs if possible and relevant)
# cat /srv/salt/test.sls
Install lvm2:
pkg.installed:
- name: lvm2
# This package is already installed as an "lvm2" dependencies
Install lvm2-libs:
pkg.installed:
- name: lvm2-libs
- require:
- pkg: Install lvm2
# I would expect this to not remove "lvm2-libs"
Remove lvm2:
pkg.removed:
- name: lvm2
- require:
- pkg: Install lvm2
$ salt-call --local state.sls test
local:
----------
ID: Install lvm2
Function: pkg.installed
Name: lvm2
Result: True
Comment: The following packages were installed/updated: lvm2
Started: 16:46:56.278371
Duration: 9790.847 ms
Changes:
----------
lvm2:
----------
new:
8:2.03.14-3.el8_6.2
old:
lvm2-libs:
----------
new:
8:2.03.14-3.el8_6.2
old:
----------
ID: Install lvm2-libs
Function: pkg.installed
Name: lvm2-libs
Result: True
Comment: All specified packages are already installed
Started: 16:47:06.100743
Duration: 868.546 ms
Changes:
----------
ID: Remove lvm2
Function: pkg.removed
Name: lvm2
Result: True
Comment: All targeted packages were removed.
Started: 16:47:06.969568
Duration: 2747.068 ms
Changes:
----------
lvm2:
----------
new:
old:
8:2.03.14-3.el8_6.2
lvm2-libs:
----------
new:
old:
8:2.03.14-3.el8_6.2
Summary for local
------------
Succeeded: 3 (changed=2)
Failed: 0
------------
Total states run: 3
Total run time: 13.406 s
Expected behavior
A clear and concise description of what you expected to happen.
From previous example, I would expect the lvm2-libs to not be removed by the pkg.removed, because the pkg.installed would have run a dnf mark install <pkg_name>.
Could be the default behavior of pkg.installed or at least have a boolean to "enforce package mark".
Screenshots
If applicable, add screenshots to help explain your problem.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3004.2
Dependency Versions:
cffi: 1.11.5
cherrypy: Not Installed
dateutil: 2.6.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.10.1
libgit2: Not Installed
M2Crypto: 0.35.2
Mako: Not Installed
msgpack: 0.6.2
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.14
pycrypto: Not Installed
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Apr 12 2022, 06:55:39)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 19.0.0
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: rocky 8.6 Green Obsidian
locale: UTF-8
machine: x86_64
release: 4.18.0-372.19.1.el8_6.x86_64
system: Linux
version: Rocky Linux 8.6 Green Obsidian
Additional context
Maybe, it's a feature but to me, it's kind of a bug according to the example I described
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 from the pkg.installed and pkg.removed behavior on a Rocky Linux 8.6 system using dnf, reproducing the provided test.sls sequence. Investigate how an installed dependency is marked and verify that removing lvm2 leaves lvm2-libs installed; done means the expected package-mark behavior works without breaking existing package states.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, 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