saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.15k stars 5.48k forks source link

state pkg.installed will fail if multiples of them are defined (yum) #41330

Closed deuscapturus closed 7 years ago

deuscapturus commented 7 years ago

Description of Issue/Question

A state with multiple pkg.installed state id's will fail after the first pkg.installed state id runs. All subsequent ones will fail with error:

State 'pkg.installed' was not found in SLS 'test'
Reason: 'pkg' __virtual__ returned False

This could be a problem that is specific to Fedora 25 or yum. I've confirmed the issue in both 2015.11.3 and 2016.11.5

Setup

test-failure.sls

aspell-ar:
  pkg.installed

aspell-he:
  pkg.installed

aspell-cs:
  pkg.installed

Steps to Reproduce Issue

[root@localhost salt]# salt-call state.apply test-failure
local:
----------
          ID: aspell-ar
    Function: pkg.installed
      Result: True
     Comment: The following packages were installed/updated: aspell-ar
     Started: 14:18:53.840951
    Duration: 8808.443 ms
     Changes:   
              ----------
              aspell:
                  ----------
                  new:
                      12:0.60.6.1-14.fc25
                  old:
              aspell-ar:
                  ----------
                  new:
                      1.2-15.fc24
                  old:
----------
          ID: aspell-he
    Function: pkg.installed
      Result: False
     Comment: State 'pkg.installed' was not found in SLS 'test'
              Reason: 'pkg' __virtual__ returned False
     Changes:   
----------
          ID: aspell-cs
    Function: pkg.installed
      Result: False
     Comment: State 'pkg.installed' was not found in SLS 'test'
              Reason: 'pkg' __virtual__ returned False
     Changes:   

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

Versions Report

[root@localhost srv]# salt-call --versions-report
Salt Version:
           Salt: 2016.11.5

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8.1
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.13 (default, May 10 2017, 20:04:28)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.4.2
            ZMQ: 4.1.4

System Versions:
           dist: fedora 25 Twenty Five
        machine: x86_64
        release: 4.10.14-200.fc25.x86_64
         system: Linux
        version: Fedora 25 Twenty Five
gtmanfred commented 7 years ago

I am unable to replicate this on centos7.

let me check fedora though since I know it uses dnf.

[root@salt ~]# salt-call --local state.apply test
local:
----------
          ID: aspell-en
    Function: pkg.installed
      Result: True
     Comment: The following packages were installed/updated: aspell-en
     Started: 20:46:07.804416
    Duration: 9544.406 ms
     Changes:
              ----------
              aspell:
                  ----------
                  new:
                      12:0.60.6.1-9.el7
                  old:
              aspell-en:
                  ----------
                  new:
                      50:7.1-5.el7
                  old:
----------
          ID: aspell-sk
    Function: pkg.installed
      Result: True
     Comment: The following packages were installed/updated: aspell-sk
     Started: 20:46:17.365494
    Duration: 3095.065 ms
     Changes:
              ----------
              aspell-sk:
                  ----------
                  new:
                      2.01-7.el7
                  old:
----------
          ID: aspell-devel
    Function: pkg.installed
      Result: True
     Comment: The following packages were installed/updated: aspell-devel
     Started: 20:46:20.473034
    Duration: 2566.958 ms
     Changes:
              ----------
              aspell-devel:
                  ----------
                  new:
                      12:0.60.6.1-9.el7
                  old:

Summary for local
------------
Succeeded: 3 (changed=3)
Failed:    0
------------
Total states run:     3
Total run time:  15.206 s
gtmanfred commented 7 years ago

Yup, I can replicate this on fedora

[root@fedora-512mb-nyc3-01 ~]# salt-call --local state.apply test
[ERROR   ] Failed to import module yumpkg, this is due most likely to a syntax error:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1332, in _load_module
    mod = imp.load_module(mod_namespace, fn_, fpath, desc)
  File "/usr/lib/python2.7/site-packages/salt/modules/yumpkg.py", line 35, in <module>
    import yum
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 52, in <module>
    _wrap_yum_i18n__ = yum.i18n._
AttributeError: 'module' object has no attribute 'i18n'
[ERROR   ] State 'pkg.installed' was not found in SLS 'test'
Reason: 'pkg' __virtual__ returned False

[ERROR   ] State 'pkg.installed' was not found in SLS 'test'
Reason: 'pkg' __virtual__ returned False

local:
----------
          ID: aspell-ar
    Function: pkg.installed
      Result: True
     Comment: The following packages were installed/updated: aspell-ar
     Started: 20:50:01.270426
    Duration: 7765.521 ms
     Changes:
              ----------
              aspell:
                  ----------
                  new:
                      12:0.60.6.1-14.fc25
                  old:
              aspell-ar:
                  ----------
                  new:
                      1.2-15.fc24
                  old:
----------
          ID: aspell-he
    Function: pkg.installed
      Result: False
     Comment: State 'pkg.installed' was not found in SLS 'test'
              Reason: 'pkg' __virtual__ returned False
     Changes:
----------
          ID: aspell-cs
    Function: pkg.installed
      Result: False
     Comment: State 'pkg.installed' was not found in SLS 'test'
              Reason: 'pkg' __virtual__ returned False
     Changes:

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

Let me do a bisect and figure out when this started.

Thanks, Daniel

gtmanfred commented 7 years ago

So, I did a dnf update and the problem went away and i can run the state.

can you try updating the full system?

Thanks, Daniel

deuscapturus commented 7 years ago

Confirmed. The issue was resolved after updating curl

dnf -y update curl libcurl libidn2
gtmanfred commented 7 years ago

AWesome! Thanks for the follow up!

Daniel On Fri, May 19, 2017 at 9:53 AM Theodore Cowan notifications@github.com wrote:

Confirmed. The issue was resolved after updating curl

dnf -y update curl libcurl libidn2

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/saltstack/salt/issues/41330#issuecomment-302740875, or mute the thread https://github.com/notifications/unsubscribe-auth/AAssoeaqS4eO96LKa7_bqbO-n8J2b9Dcks5r7brYgaJpZM4NfwMc .

maennlse commented 6 years ago

https://github.com/saltstack/salt/issues/41330

I currently have the same(?) issue - at least the same error output - while applying a state using orchestration.

the state file contains several pkg.installed functions and fails after the first function is run. if i manually run the state again (after orchestration has failed) the state is applied successfully.

minion is fedora26 (fresh install/updated 2017.7.2-1.fc26) master is centos7 (2017.7.2-1.el7)


Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1412, in _load_module
    mod = imp.load_module(mod_namespace, fn_, fpath, desc)
  File "/usr/lib/python2.7/site-packages/salt/modules/yumpkg.py", line 35, in <module>
    import yum
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 62, in <module>
    import rpmsack
  File "/usr/lib/python2.7/site-packages/yum/rpmsack.py", line 38, in <module>
    import yum.depsolve
  File "/usr/lib/python2.7/site-packages/yum/depsolve.py", line 57, in <module>
    flags = {"GT": rpm.RPMSENSE_GREATER,
AttributeError: 'module' object has no attribute 'RPMSENSE_GREATER'
2017-11-14 15:15:04,177 [tornado.application][ERROR   ][139] Exception in callback <functools.partial object at 0x7fc1df4d9f18>
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/tornado/ioloop.py", line 603, in _run_callback
    ret = callback()
  File "/usr/lib64/python2.7/site-packages/tornado/stack_context.py", line 274, in null_wrapper
    return fn(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/tornado/ioloop.py", line 618, in <lambda>
    self.add_future(ret, lambda f: f.result())
  File "/usr/lib64/python2.7/site-packages/tornado/concurrent.py", line 236, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 1021, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/lib/python2.7/site-packages/salt/minion.py", line 817, in handle_event
    yield [minion.handle_event(package) for minion in self.minions]
  File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 1015, in run
    value = future.result()
  File "/usr/lib64/python2.7/site-packages/tornado/concurrent.py", line 236, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 792, in callback
    result_list.append(f.result())
  File "/usr/lib64/python2.7/site-packages/tornado/concurrent.py", line 236, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 285, in wrapper
    yielded = next(result)
  File "/usr/lib/python2.7/site-packages/salt/minion.py", line 1970, in handle_event
    notify=data.get('notify', False)
  File "/usr/lib/python2.7/site-packages/salt/minion.py", line 1809, in module_refresh
    self.functions, self.returners, _, self.executors = self._load_modules(force_refresh, notify=notify)
  File "/usr/lib/python2.7/site-packages/salt/minion.py", line 1207, in _load_modules
    self.opts['grains'] = salt.loader.grains(self.opts, force_refresh, proxy=proxy)
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 717, in grains
    ret = funcs[key]()
  File "/usr/lib/python2.7/site-packages/salt/grains/core.py", line 1652, in os_data
    grains.update(_hw_data(grains))
  File "/usr/lib/python2.7/site-packages/salt/grains/core.py", line 2027, in _hw_data
    'biosversion': __salt__['smbios.get']('bios-version'),
  File "/usr/lib/python2.7/site-packages/salt/modules/smbios.py", line 88, in get
    val = _dmidecoder('-s {0}'.format(string)).strip()
  File "/usr/lib/python2.7/site-packages/salt/modules/smbios.py", line 334, in _dmidecoder
    return salt.modules.cmdmod._run_quiet('{0} {1}'.format(DMIDECODER, args))
  File "/usr/lib/python2.7/site-packages/salt/modules/cmdmod.py", line 709, in _run_quiet
    pillar_override=pillar_override)['stdout']
  File "/usr/lib/python2.7/site-packages/salt/modules/cmdmod.py", line 567, in _run
    raise CommandExecutionError(msg)
CommandExecutionError: Unable to run command 'REDACTED' with the context '{'timeout': None, 'with_communicate': True, 'shell': False, 'bg': False, 'stderr': -2, 'env': {'LC_NUMERIC': 'C', 'NOTIFY_SOCKET': '/run/systemd/notify', 'LC_ADDRESS': 'C', 'LC_CTYPE': 'C', 'LC_PAPER': 'C', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin', 'LC_IDENTIFICATION': 'C', 'LC_MESSAGES': 'C', 'JOURNAL_STREAM': '9:1389707', 'LC_MONETARY': 'C', 'LC_COLLATE': 'C', 'LC_TELEPHONE': 'C', 'LC_MEASUREMENT': 'C', 'LC_NAME': 'C', 'LC_TIME': 'C', 'INVOCATION_ID': 'fb625cd1d8d84562b1392ace586b2db8'}, 'stdout': -1, 'close_fds': True, 'stdin': None, 'cwd': '/root'}', reason: command not found
2017-11-14 15:15:04,985 [salt.state       ][ERROR   ][27135] State 'pkg.installed' was not found in SLS 'installpackages00'
Reason: 'pkg' __virtual__ returned False

2017-11-14 15:15:04,985 [salt.state       ][ERROR   ][27135] State 'pkg.installed' was not found in SLS 'installpackages00'
Reason: 'pkg' __virtual__ returned False

does not fail on centos7 clients with minion 2017.7.2-1.el7

are there any known bugs/limitations?

i currently 'work around', splitting the pkg.installed functions in separate state files and orchestrate them one after the other.

Thanks, Sebastian

dOpsCoder commented 6 years ago

Hey @gtmanfred @deuscapturus Can you guys share what was the relation between curl version and the error you saw? I have similar issue and can't easily upgrade libcurl or curl.