Problem of the fun dictionary value being overwritten
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue
Problem of automatic overwritting the set value to the dictionary, when using reactor to post an event on a queue.
Setup
(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)
reactor.conf
reactor:
- 'salt/beacon/*/iptables/exceeded':
- salt://reactors/schedule_queue.sls
schedule_queue.sls
{%- set split_tag = tag.split('/') -%}
{%- set orch_fun = split_tag[-2::1]|join('.') -%}
{%- set queue = split_tag[-2::1]|join('_') -%}
invoke_queue_scheduler:
runner.queue.insert_runner:
- fun: state.orchestrate
- kwargs:
mods: orch.{{ orch_fun }}
pillar:
id: {{ data['id'] }}
- queue: {{ queue }}
- backend: pgjsonb
Steps to Reproduce Issue
- Configure schedule_queue.sls on reactors folder
- Configure the reactor.conf
- Trigger the reactor from a minion with the following code:
salt-call event.send tag='salt/beacon/*/iptables/exceeded'
(Include debug logs if possible and relevant.)
The salt renders and uses the correct information
[PROFILE ] Time (in seconds) to render '/var/cache/salt/master/files/base/reactors/schedule_queue.sls' using 'jinja' renderer: 0.06471872329711914
[DEBUG ] Rendered data from file: /var/cache/salt/master/files/base/reactors/schedule_queue.sls:
invoke_queue_scheduler:
runner.queue.insert_runner:
- fun: state.orchestrate
- kwargs:
mods: orch.iptables.exceeded
pillar:
id: mesos2.host.intranet
- queue: iptables_exceeded
- backend: pgjsonb
[DEBUG ] Results of YAML rendering:
OrderedDict([('invoke_queue_scheduler', OrderedDict([('runner.queue.insert_runner', [OrderedDict([('fun', 'state.orchestrate')]), OrderedDict([('kwargs', OrderedDict([('mods', 'orch.iptables.exceeded'), (
'pillar', OrderedDict([('id', 'mesos2.host.intranet')]))]))]), OrderedDict([('queue', 'iptables_exceeded')]), OrderedDict([('backend', 'pgjsonb')])])]))])
[PROFILE ] Time (in seconds) to render '/var/cache/salt/master/files/base/reactors/schedule_queue.sls' using 'yaml' renderer: 0.0008614063262939453
But when sending the data he sets runner.queue.insert_runner instead of iptables_exceeded
[DEBUG ] Sending event: tag = salt/run/20200303165210089774/new; data = {'fun': 'runner.queue.insert_runner', 'jid': '20200303165210089774', 'user': 'Reactor', 'fun_args': ['queue.insert_runner', {'back
end': 'pgjsonb', 'queue': 'iptables_exceeded', 'kwargs': OrderedDict([('mods', 'orch.iptables.exceeded'), ('pillar', OrderedDict([('id', 'mesos2.host.intranet')]))]), 'args': None}], '_stamp': '2020-03-03
T16:52:10.092216'}
[DEBUG ] LazyLoaded pgjsonb.insert
[DEBUG ] SQL Query: select relname from pg_class where relkind='r' and relname !~ '^(pg_|sql_)';
[DEBUG ] Queue iptables_exceeded already exists.
[DEBUG ] SQL Query: INSERT INTO iptables_exceeded(data) VALUES('{"fun": "queue.insert_runner", "args": [], "kwargs": {"mods": "orch.iptables.exceeded", "pillar": {"id": "mesos2.host.intranet"}}}')
[DEBUG ] LazyLoaded local_cache.prep_jid
[DEBUG ] Sending event: tag = salt/run/20200303165210089774/ret; data = {'fun': 'runner.queue.insert_runner', 'jid': '20200303165210089774', 'user': 'Reactor', 'fun_args': ['queue.insert_runner', {'back
end': 'pgjsonb', 'queue': 'iptables_exceeded', 'kwargs': OrderedDict([('mods', 'orch.iptables.exceeded'), ('pillar', OrderedDict([('id', 'mesos2.host.intranet')]))]), 'args': None}], '_stamp': '2020-03-0$
T16:52:10.129837', 'return': True, 'success': True}
[DEBUG ] LazyLoaded nested.output
True
Return when listing items:
[root@salt-master /]# salt-run queue.list_items iptables_exceeded backend=pgjsonb
|_
----------
args:
fun:
queue.insert_runner
kwargs:
----------
mods:
orch.iptables.exceeded
pillar:
----------
id:
mesos2.host.intranet
Versions Report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
[root@salt-master /]# salt --version │[DEBUG ] SaltReqTimeoutError, retrying. (1/3) │1 bash
salt 3000
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 reactor configuration in reactor.conf and schedule_queue.sls, then trace runner.queue.insert_runner and the pgjsonb backend using the supplied debug output. Compare the rendered runner arguments with the data stored by queue.list_items; done means the requested state.orchestrate function and arguments remain intact, with a regression test for this reactor path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- backend, databases, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100