saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

[BUG] KeyError: '/usr/lib/python39.zip' #61808

Open ichilton opened 2 years ago

ichilton commented 2 years ago

Description

Using salt proxy minions with Arista EOS switches, it works most of the time, but sometimes get this error:

     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python3/dist-packages/salt/state.py", line 2179, in call
                  ret = self.states[cdata["full"]](
                File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1249, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python3/dist-packages/salt/states/netconfig.py", line 836, in managed
                  config_update_ret = _update_config(
                File "/usr/lib/python3/dist-packages/salt/states/netconfig.py", line 78, in _update_config
                  return __salt__["net.load_template"](
                File "/usr/lib/python3/dist-packages/salt/loader/context.py", line 78, in __getitem__
                  return self.value()[item]
                File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 334, in __getitem__
                  super().__getitem__(item)  # try to get the item from the dictionary
                File "/usr/lib/python3/dist-packages/salt/utils/lazy.py", line 98, in __getitem__
                  if self._load(key):
                File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1033, in _load
                  ret = _inner_load(mod_name)
                File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1022, in _inner_load
                  if self._load_module(name) and key in self._dict:
                File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 822, in _load_module
                  self.__clean_sys_path()
                File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 641, in __clean_sys_path
                  importlib.invalidate_caches()
                File "/usr/lib/python3.9/importlib/__init__.py", line 71, in invalidate_caches
                  finder.invalidate_caches()
                File "<frozen importlib._bootstrap_external>", line 1255, in invalidate_caches
              KeyError: '/usr/lib/python39.zip'
     Started: 14:14:33.015826
    Duration: 637.435 ms
     Changes:

On the next run it works ok again.

Setup

salt master and salt proxy minion running under Debian Linux (bullseye).

Steps to Reproduce the behavior

Just running state.highstate

Expected behavior

It should work every time.

Versions Report

$ salt --versions-report
Salt Version:
          Salt: 3004

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.3
       libgit2: 1.1.0
      M2Crypto: 0.37.1
          Mako: Not Installed
       msgpack: 1.0.0
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.20
      pycrypto: Not Installed
  pycryptodome: 3.9.7
        pygit2: 1.4.0
        Python: 3.9.2 (default, Feb 28 2021, 17:03:44)
  python-gnupg: Not Installed
        PyYAML: 5.3.1
         PyZMQ: 20.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: debian 11 bullseye
        locale: utf-8
       machine: x86_64
       release: 5.10.0-9-amd64
        system: Linux
       version: Debian GNU/Linux 11 bullseye

n-holmstedt commented 2 years ago

Same as https://github.com/saltstack/salt/issues/61734

I'm running a version in production that catches theese key errors in the lazy loader and it seems to work. It seems to be a concurrency issue with processes deleting values at the same time.