[BUG] KeyError: '/usr/lib/python39.zip'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with salt/loader/lazy.py, especially __clean_sys_path and the importlib.invalidate_caches call shown in the traceback; review how state.highstate reaches it through salt/states/netconfig.py. Reproduce on the reported Debian 11, Python 3.9, Salt 3004 setup by running state.highstate repeatedly, and consider the issue resolved when it no longer intermittently raises KeyError for /usr/lib/python39.zip.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100