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 aggregate does not honor requires requisite #65304

Closed
2 tasks
bdrx312 opened this issue Sep 27, 2023 · 4 comments
Closed
2 tasks

[BUG] pkg.installed state aggregate does not honor requires requisite #65304

bdrx312 opened this issue Sep 27, 2023 · 4 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior needs-triage State-Compiler

Comments

@bdrx312
Copy link
Contributor

bdrx312 commented Sep 27, 2023

Description

Setting state_aggregate: True causes packages in a pkg.installed state to be installed before specified requires requisite.

Setup

Please be as specific as possible and give set-up details.

  • vagrant fedora vm
  • masterless

Steps to Reproduce the behavior

  • Setup directories and files; set minion to have state_aggregate: True;

    cat > /etc/salt/minion <<'EOF'
    file_client: local
    master_type: disable
    state_aggregate: True
    EOF
    
    mkdir /srv/salt /srv/pillar /srv/salt/_grains
    cat > /srv/salt/top.sls <<'EOF'
    base:
      '*':
        - test
    EOF
    
    cat > /srv/salt/test.sls <<'EOF'
    "first packages":
      pkg.installed:
        - pkgs:
          - drpm
    
    "requirement":
      test.nop: []
    
    "second packages":
      pkg.installed:
        - pkgs:
          - gc
        - require:
          - "requirement"
    EOF
  • Run state.apply which installs the package(s) from the "second packages" state before the required "requirement" state.

salt-call -l info --local state.apply
$ salt-call --local -l info state.apply
[INFO    ] Loading fresh modules for state activity
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/clouds'
[INFO    ] Syncing clouds for environment 'base'
[INFO    ] Loading cache from salt://_clouds, for base
[INFO    ] Caching directory '_clouds/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/beacons'
[INFO    ] Syncing beacons for environment 'base'
[INFO    ] Loading cache from salt://_beacons, for base
[INFO    ] Caching directory '_beacons/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/modules'
[INFO    ] Syncing modules for environment 'base'
[INFO    ] Loading cache from salt://_modules, for base
[INFO    ] Caching directory '_modules/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/states'
[INFO    ] Syncing states for environment 'base'
[INFO    ] Loading cache from salt://_states, for base
[INFO    ] Caching directory '_states/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/sdb'
[INFO    ] Syncing sdb for environment 'base'
[INFO    ] Loading cache from salt://_sdb, for base
[INFO    ] Caching directory '_sdb/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/grains'
[INFO    ] Syncing grains for environment 'base'
[INFO    ] Loading cache from salt://_grains, for base
[INFO    ] Caching directory '_grains/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/renderers'
[INFO    ] Syncing renderers for environment 'base'
[INFO    ] Loading cache from salt://_renderers, for base
[INFO    ] Caching directory '_renderers/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/returners'
[INFO    ] Syncing returners for environment 'base'
[INFO    ] Loading cache from salt://_returners, for base
[INFO    ] Caching directory '_returners/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/output'
[INFO    ] Syncing output for environment 'base'
[INFO    ] Loading cache from salt://_output, for base
[INFO    ] Caching directory '_output/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/utils'
[INFO    ] Syncing utils for environment 'base'
[INFO    ] Loading cache from salt://_utils, for base
[INFO    ] Caching directory '_utils/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/log_handlers'
[INFO    ] Syncing log_handlers for environment 'base'
[INFO    ] Loading cache from salt://_log_handlers, for base
[INFO    ] Caching directory '_log_handlers/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/executors'
[INFO    ] Syncing executors for environment 'base'
[INFO    ] Loading cache from salt://_executors, for base
[INFO    ] Caching directory '_executors/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/proxy'
[INFO    ] Syncing proxy for environment 'base'
[INFO    ] Loading cache from salt://_proxy, for base
[INFO    ] Caching directory '_proxy/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/engines'
[INFO    ] Syncing engines for environment 'base'
[INFO    ] Loading cache from salt://_engines, for base
[INFO    ] Caching directory '_engines/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/thorium'
[INFO    ] Syncing thorium for environment 'base'
[INFO    ] Loading cache from salt://_thorium, for base
[INFO    ] Caching directory '_thorium/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/serializers'
[INFO    ] Syncing serializers for environment 'base'
[INFO    ] Loading cache from salt://_serializers, for base
[INFO    ] Caching directory '_serializers/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/matchers'
[INFO    ] Syncing matchers for environment 'base'
[INFO    ] Loading cache from salt://_matchers, for base
[INFO    ] Caching directory '_matchers/' for environment 'base'
[INFO    ] Creating module dir '/var/cache/salt/minion/extmods/pillar'
[INFO    ] Syncing pillar for environment 'base'
[INFO    ] Loading cache from salt://_pillar, for base
[INFO    ] Caching directory '_pillar/' for environment 'base'
[INFO    ] Loading fresh modules for state activity
[INFO    ] Fetching file from saltenv 'base', ** done ** 'test.sls'
/usr/lib/python3.11/site-packages/salt/utils/pycrypto.py:26: DeprecationWarning: 'crypt' is deprecated and slated for removal in Python 3.13
  import crypt
/usr/lib/python3.11/site-packages/salt/modules/linux_shadow.py:21: DeprecationWarning: 'spwd' is deprecated and slated for removal in Python 3.13
  import spwd
[INFO    ] Running state [first packages] at time 02:51:37.173427
[INFO    ] Executing state pkg.installed for [first packages]
[INFO    ] Executing command rpm in directory '/root'
[INFO    ] Executing command systemd-run in directory '/root'
[INFO    ] Executing command systemd-run in directory '/root'
[WARNING ] 'version' argument will be ignored for multiple package targets
[INFO    ] Executing command systemd-run in directory '/root'
[INFO    ] Executing command rpm in directory '/root'
[INFO    ] Made the following changes:
'drpm' changed from 'absent' to '0.5.2-1.fc38'
'gc' changed from 'absent' to '8.2.2-3.fc38'

[INFO    ] Loading fresh modules for state activity
[INFO    ] Completed state [first packages] at time 02:51:46.412181 (duration_in_ms=9238.755)
[INFO    ] Running state [requirement] at time 02:51:47.755257
[INFO    ] Executing state test.nop for [requirement]
[INFO    ] Success!
[INFO    ] Completed state [requirement] at time 02:51:47.761107 (duration_in_ms=5.851)
[INFO    ] Running state [second packages] at time 02:51:47.762141
[INFO    ] Executing state pkg.installed for [second packages]
[INFO    ] All specified packages are already installed
[INFO    ] Completed state [second packages] at time 02:51:47.789906 (duration_in_ms=27.765)
local:
----------
          ID: first packages
    Function: pkg.installed
      Result: True
     Comment: The following packages were installed/updated: drpm, gc
     Started: 02:51:37.173426
    Duration: 9238.755 ms
     Changes:
              ----------
              drpm:
                  ----------
                  new:
                      0.5.2-1.fc38
                  old:
              gc:
                  ----------
                  new:
                      8.2.2-3.fc38
                  old:
----------
          ID: requirement
    Function: test.nop
      Result: True
     Comment: Success!
     Started: 02:51:47.755256
    Duration: 5.851 ms
     Changes:
----------
          ID: second packages
    Function: pkg.installed
      Result: True
     Comment: All specified packages are already installed
     Started: 02:51:47.762141
    Duration: 27.765 ms
     Changes:

Summary for local
------------
Succeeded: 3 (changed=1)
Failed:    0
------------
Total states run:     3
Total run time:   9.272 s

Expected behavior
The packages from a state that has a state specified as a requires requisite should not be installed until the required state has run; for the given test case example the gc from "second packages" state should not be installed until after the "requirement" state has been run.

Versions Report

salt --versions-report
Salt Version:
          Salt: 3006.3

Python Version:
        Python: 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 13.0.1 20230208 (Red Hat 13.0.1-0)]

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.0.3
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.4
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.0
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.17.0
        pygit2: Not Installed
  python-gnupg: Not Installed
        PyYAML: 6.0
         PyZMQ: 24.0.1
        relenv: Not Installed
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: fedora 38
        locale: utf-8
       machine: x86_64
       release: 6.2.9-300.fc38.x86_64
        system: Linux
       version: Fedora Linux 38

Additional context
I used the following vagrant file for the simple test case

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  # config.vm.box = "bento/ubuntu-22.04"
  config.vm.box = "fedora/38-cloud-base"
  # config.vm.box = "centos/stream8"
  config.vm.hostname = 'salt-test-box'

  # Give the machine 2048MB of RAM.
  # This assumes you're using the virtualbox provider, see
  # https://www.vagrantup.com/docs/providers/ for information on the
  # other providers.
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "2048"
  end

  # config.vm.synced_folder "salt", "/srv/salt", :nfs => false
  # # required for nfs shared folder
  # config.vm.network "private_network", type: "dhcp"

  # config.vm.provision :salt do |salt|
  #   salt.install_type = "stable"
  #   salt.masterless = true
  #   salt.minion_config = "salt/minion"
  #   salt.run_highstate = true
  # end
end

The problem was also experienced on RHEL 8.7 onedir installation.

@bdrx312 bdrx312 added Bug broken, incorrect, or confusing behavior needs-triage labels Sep 27, 2023
@frebib
Copy link
Contributor

frebib commented Oct 4, 2023

See also #62439

@bdrx312
Copy link
Contributor Author

bdrx312 commented Nov 7, 2023

The ability to aggregate yum package installations was the primary feature that attracted us to salt over other tools like puppet or ansible. This is an important feature to be fixed for us since we need the performance benefit of being able to aggregate the package installations.

@garethgreenaway
Copy link
Contributor

I suspect that the fix was included in https://github.com/saltstack/salt/pull/62529/files may have broken this functionality, with a fix that I now believe wasn't the correct fix.

@purpleidea
Copy link

@bdrx312

The ability to aggregate yum package installations was the primary feature that attracted us to salt over other tools like puppet or ansible. This is an important feature to be fixed for us since we need the performance benefit of being able to aggregate the package installations.

This is a feature that AFAICT the https://github.com/purpleidea/mgmt/ project invented and has existed there since the beginning. I'd love to hear more about your use case for it. We call it autogrouping.

@Akm0d Akm0d self-assigned this Mar 26, 2024
@Akm0d Akm0d closed this as completed Jun 18, 2024
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 State-Compiler
Projects
None yet
Development

No branches or pull requests

6 participants