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

[BUG] pkg.installed state with dnf should mark the package as installed #62441

Open
TeddyAndrieux opened this issue Aug 8, 2022 · 4 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@TeddyAndrieux
Copy link
Contributor

TeddyAndrieux commented Aug 8, 2022

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

@TeddyAndrieux TeddyAndrieux added Bug broken, incorrect, or confusing behavior needs-triage labels Aug 8, 2022
TeddyAndrieux added a commit to scality/metalk8s that referenced this issue Aug 9, 2022
Ensure that on RHEL 8 based OS, packages installed by MetalK8s
are marked as "installed by user" so that they do not get removed
as "unused dependencies".

This commit also fix a bug where the `kubelet` package get removed
in post-upgrade step that remove the `calico-cni-plugin` package.

See: saltstack/salt#62441
@OrangeDog
Copy link
Contributor

This would be applicable to apt systems too.

@CrackerJackMack
Copy link

This would be applicable to apt systems too.

apt-mark manual <package>

but anything installed with apt-get/aptitude/apt should automatically have these packages marked as manually installed. Have you observed the same behavior in apt based systems? ref: https://github.com/saltstack/salt/blob/master/salt/modules/aptpkg.py#L821-L853

@OrangeDog
Copy link
Contributor

OrangeDog commented Aug 15, 2022 via email

@CrackerJackMack
Copy link

CrackerJackMack commented Aug 18, 2022

@OrangeDog thanks for that clarification, makes a ton of sense now.
edit: also I am dumb

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 needs-triage
Projects
None yet
Development

No branches or pull requests

3 participants