[BUG] salt.thorium.reg.clear clears a level of dict too much
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
I try to fire a single action in response to many events (one from each minion).
So I use the following example code:
patch_grp2:
reg.set:
- add: host
- match: custom/system/up
check.contains:
- value: mysystem1
- value: mysystem2
shell_test:
local.cmd:
- tgt: '*'
- func: cmd.run
- arg:
- echo 'thorium success' > /tmp/thorium.txt
- require:
- check: patch_grp2
reg.clear:
- name: patch_grp2
And on mysystem1/2 I do:
salt-call event.send custom/system/up "{host: $(hostname -s)}"
It works as expected: /tmp/thorium.txt is created after both minions sent the event.
But since the action is triggered multiple times (e.g. if I rm /tmp/thorium.txt on a minion, file is instantly recreated), I do the reg.clear in my action.
If seems this would solve my problem, but there seems to be a bug:
The clear triggers and I get the following error in Log
2020-07-02 14:59:11,525 [salt.state :322 ][ERROR ][1412] An exception occurred in this state: Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/salt/state.py", line 1981, in call
**cdata['kwargs'])
File "/usr/local/lib/python3.6/dist-packages/salt/loader.py", line 1977, in wrapper
return f(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/salt/thorium/check.py", line 270, in contains
if value in __reg__[name]['val']:
KeyError: 'val'
After that the Thorium register doesn't work at all until master restart.
I guess you want to clear the contents of __reg__[name]['val'] but actually you do clear __reg__[name] ?
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3000.2
Dependency Versions:
cffi: Not Installed
cherrypy: unknown
dateutil: 2.6.1
docker-py: Not Installed
gitdb: 2.0.3
gitpython: 2.1.8
Jinja2: 2.11.2
libgit2: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.6.2
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.9 (default, Apr 18 2020, 01:56:04)
python-gnupg: 0.4.1
PyYAML: 5.3.1
PyZMQ: 19.0.0
smmap: 2.0.3
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.2
System Versions:
dist: Ubuntu 18.04 bionic
locale: UTF-8
machine: x86_64
release: 4.15.0-96-generic
system: Linux
version: Ubuntu 18.04 bionic
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 the salt.thorium.reg.clear entry point and salt/thorium/check.py at the contains function and reported KeyError. Trace how clearing patch_grp2 changes the register, then add or update focused coverage so clearing does not break subsequent event handling and the register continues working without a master restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100