Problem of the fun dictionary value being overwritten
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
@luishmg Thanks for the report. I was able to reproduce this. We'll get this fixed up.
@luishmg Upon further investigation I'm confused by what the expectation for this is. The queue in this case is iptables_exceeded and the function is runner.queue.insert_runner, which is the value of the runner function being called. I'm not sure how iptables_exceeded would end up as the function in this scenario.
@garethgreenaway my bad runner.queue.insert_runner is being send instead of state.orchestrate, this is problably related of the fact that fun is used by salt system and the module runner.queue is using it, because when i changed the fun variable to function on the module it worked. What I'm trying to do is create a reactor to populate a runner queue
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
needs follow up @garethgreenaway
Is this still being looked at? if needed to be worked on I would like to pick it up.
@sudo-k-runner we did not have enough resources in the Magnesium release cycle to pick it up, would you like to work on it in the next release cycle, Aluminium? I will have the dates for that in the next 5-10 days, GA date is end of February 2021 and planning and code freeze dates are the few that I need to still work out with the team.
Can I pick this issue up? This is my first time working on an open source project. Hopefully I can help
Is someone still working on this issue? If not, can I work on this issue?
Closing as part of a backlog cleanup — this issue was filed without a Salt versions-report, so there's no explicit version attached to compare against.
If you (or anyone else) can still reproduce this on 3008.3 or later, please comment with:
- A fresh reproduction
- The output of
salt --versions-report
and the issue will be reopened. The original reporter can also reopen directly.