salt icon indicating copy to clipboard operation
salt copied to clipboard

kmod.present should return succeed if some modules already loaded.

Open xyoun opened this issue 8 years ago • 1 comments

Description of Issue/Question

when using kmod.present, if some of the modules has already loaded. if the rest loaded succeed, the return should be success, not failed.

Setup

(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)

Ensure nf_conntrack loaded:
  kmod.present:
    - mods:
      - loop
      - nf_nat
      - nf_nat_ipv4
      - nf_conntrack_ipv4
      - nf_conntrack

Steps to Reproduce Issue

sudo salt-call state.sls nf_conntrack
[ERROR   ] {'nf_nat_ipv4': 'loaded', 'nf_conntrack': 'loaded', 'nf_conntrack_ipv4': 'loaded', 'nf_defrag_ipv4': 'loaded', 'nf_nat': 'loaded'}
local:
----------
          ID: Ensure nf_conntrack loaded
    Function: kmod.present
      Result: False
     Comment: Kernel module loop is already present
              Loaded kernel module nf_nat_ipv4
              Failed to load kernel modules nf_conntrack, nf_conntrack_ipv4, nf_nat
     Started: 16:58:36.513341
    Duration: 704.938 ms
     Changes:
              ----------
              nf_conntrack:
                  loaded
              nf_conntrack_ipv4:
                  loaded
              nf_defrag_ipv4:
                  loaded
              nf_nat:
                  loaded
              nf_nat_ipv4:
                  loaded

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time: 726.775 ms

Versions Report

Salt Version:
           Salt: 2017.7.2

Dependency Versions:
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: 2.2
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.3
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.0
   msgpack-pure: Not Installed
 msgpack-python: 0.4.2
   mysql-python: 1.2.3
      pycparser: 2.10
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.9 (default, Jun 29 2016, 13:08:31)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: debian 8.4
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-0.bpo.4-amd64
         system: Linux
        version: debian 8.4

xyoun avatar Dec 27 '17 09:12 xyoun

kmod.load uses modprobe to load modules. modprobe load all dependency modules. State does not handle such case.

root@lab-deb9-cloud02:~# salt-call kmod.load nf_nat_ipv4
local:
    - nf_conntrack
    - nf_conntrack_ipv4
    - nf_defrag_ipv4
    - nf_nat
    - nf_nat_ipv4
root@lab-deb9-cloud02:~# salt-call kmod.load nf_nat_ipv4
local:
root@lab-deb9-cloud02:~# salt-call kmod.load nf_conntrack
local:
root@lab-deb9-cloud02:~#

Fix looks simple, I'll submit patch

samodid avatar Jan 13 '18 12:01 samodid