Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem of the fun dictionary value being overwritten #56297

Open
luishmg opened this issue Mar 3, 2020 · 8 comments
Open

Problem of the fun dictionary value being overwritten #56297

luishmg opened this issue Mar 3, 2020 · 8 comments
Labels
Bug broken, incorrect, or confusing behavior good first issue good for someone new to salt Reactor severity-high 2nd top severity, seen by most users, causes major problems

Comments

@luishmg
Copy link

luishmg commented Mar 3, 2020

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

  1. Configure schedule_queue.sls on reactors folder
  2. Configure the reactor.conf
  3. 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 luishmg changed the title Problem of the fun variable being overwritten Problem of the fun dictionary value being overwritten Mar 3, 2020
@garethgreenaway garethgreenaway added Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P3 Priority 3 labels Mar 5, 2020
@garethgreenaway garethgreenaway added this to the Approved milestone Mar 5, 2020
@garethgreenaway
Copy link
Contributor

@luishmg Thanks for the report. I was able to reproduce this. We'll get this fixed up.

@garethgreenaway garethgreenaway self-assigned this Mar 5, 2020
@garethgreenaway garethgreenaway removed Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P3 Priority 3 labels Mar 5, 2020
@garethgreenaway garethgreenaway modified the milestones: Approved, Blocked Mar 5, 2020
@garethgreenaway garethgreenaway added the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Mar 5, 2020
@garethgreenaway
Copy link
Contributor

@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.

@luishmg
Copy link
Author

luishmg commented Mar 5, 2020

@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

@stale
Copy link

stale bot commented Apr 5, 2020

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.

@stale stale bot added the stale label Apr 5, 2020
@sagetherage
Copy link
Contributor

sagetherage commented Apr 10, 2020

needs follow up @garethgreenaway

@sagetherage sagetherage added info-needed waiting for more info and removed Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged stale labels Apr 10, 2020
@sagetherage sagetherage removed this from the Blocked milestone Apr 10, 2020
@sagetherage sagetherage removed the info-needed waiting for more info label Apr 10, 2020
@Akm0d Akm0d added v3000.1 vulnerable version Reactor team-core Bug broken, incorrect, or confusing behavior labels Apr 14, 2020
@Akm0d Akm0d added this to the Approved milestone Apr 14, 2020
@sagetherage sagetherage removed the v3000.1 vulnerable version label Apr 15, 2020
@sagetherage sagetherage added good first issue good for someone new to salt and removed Low-Hanging Fruit labels May 23, 2020
@sagetherage sagetherage added the Magnesium Mg release after Na prior to Al label Jul 6, 2020
@sagetherage sagetherage added the severity-high 2nd top severity, seen by most users, causes major problems label Jul 6, 2020
@sagetherage sagetherage modified the milestones: Approved, Magnesium Jul 14, 2020
@sagetherage sagetherage removed the Magnesium Mg release after Na prior to Al label Sep 29, 2020
@sagetherage sagetherage modified the milestones: Magnesium, Approved Sep 29, 2020
@sudo-k-runner
Copy link

Is this still being looked at? if needed to be worked on I would like to pick it up.

@sagetherage
Copy link
Contributor

sagetherage commented Oct 12, 2020

@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.

@sagetherage sagetherage added the Phosphorus v3005.0 Release code name and version label Jun 18, 2021
@sagetherage sagetherage modified the milestones: Approved, Phosphorus Jun 18, 2021
@Ch3LL Ch3LL removed the Phosphorus v3005.0 Release code name and version label Mar 30, 2022
@popoviciyoel
Copy link

Can I pick this issue up? This is my first time working on an open source project. Hopefully I can help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior good first issue good for someone new to salt Reactor severity-high 2nd top severity, seen by most users, causes major problems
Projects
None yet
Development

No branches or pull requests

8 participants