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

event.send double-nests data #34341

Closed
ahammond opened this issue Jun 28, 2016 · 4 comments
Closed

event.send double-nests data #34341

ahammond opened this issue Jun 28, 2016 · 4 comments
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE Execution-Module P4 Priority 4 Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around stale
Milestone

Comments

@ahammond
Copy link
Contributor

Description of Issue/Question

Calling event.send with data nests that data inside the existing data dict. This makes it impossible to for example test salt-cloud reactors without actually running salt-cloud

Setup

Run salt-cloud, observe the deploying event contains host: new_ip_address. Attempt to mock this event using the following:

#!/usr/bin/env python

import salt.client

caller = salt.client.Caller()

caller.sminion.functions['event.send'](
    'salt/cloud/test_minion_id/deploying',
    data={'kwargs': {'host': '1.2.3.4'}}
)

Observe that the generated event has data nested inside data, breaking the mock.

salt/cloud/test_minion_id/deploying {"_stamp": "2016-06-28T18:36:35.656586", "pretag": null, "cmd": "_minion_event", "tag": "salt/cloud/test_minion_id/deploying", "data": {"kwargs": {"host": "1.2.3.4"}}, "id": "salt"}

There appears to be no way to actually insert entires directly in the data object.

Versions Report

root@salt:~# salt-call --versions-report
Salt Version:
           Salt: 2016.3.1

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.5
          gitdb: 0.6.4
      gitpython: 2.0.6
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 0.9.1
   msgpack-pure: Not Installed
 msgpack-python: 0.3.0
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.0.1
           RAET: Not Installed
          smmap: 0.9.0
        timelib: 0.2.4
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: Ubuntu 14.04 trusty
        machine: x86_64
        release: 4.2.0-38-generic
         system: Linux
        version: Ubuntu 14.04 trusty
@Ch3LL
Copy link
Contributor

Ch3LL commented Jun 29, 2016

@ahammond I am seeing this behavior as well. I believe this is because it seems like most other events have the data kwarg attached to it, but when running salt-cloud it seems that is not in that event. So seems we need to add option to not include that in the event.

@Ch3LL Ch3LL added Bug broken, incorrect, or confusing behavior P4 Priority 4 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around Core relates to code central or existential to Salt Execution-Module labels Jun 29, 2016
@Ch3LL Ch3LL added this to the Approved milestone Jun 29, 2016
@Ch3LL Ch3LL added the Confirmed Salt engineer has confirmed bug/feature - often including a MCVE label Jun 29, 2016
@ahammond
Copy link
Contributor Author

data.data is is ugly and non-intuitive to me. Either way, I need to be able to mock the salt-cloud events in order to test my code without actually running salt-cloud. :)

@meggiebot meggiebot added Platform Relates to OS, containers, platform-based utilities like FS, system based apps and removed Core relates to code central or existential to Salt labels Sep 19, 2016
@blbradley
Copy link
Contributor

I'm still experiencing this is 2017.7.1 with the Salt Cloud created event. Here's my nested data dict:

salt-call event.send 'salt/cloud/ceetah1-south/created' data='{"name": "ceetah1-south"}'

2017-09-23 13:59:48,169 [salt.utils.event ][DEBUG   ][8499] Sending event: tag = salt/job/20170923135948169040/ret/salt-master1; data = {'tgt_type': 'glob', 'fun_args': ['salt/cloud/ceetah1-south/created', 'data={"name": "ceetah1-south"}'], 'jid': '20170923135948169040', 'return': True, 'retcode': 0, 'tgt': 'salt-master1', 'cmd': '_return', '_stamp': '2017-09-23T18:59:48.169655', 'arg': ['salt/cloud/ceetah1-south/created', 'data={"name": "ceetah1-south"}'], 'fun': 'event.send', 'id': 'my-salt-master'}

@stale
Copy link

stale bot commented Feb 7, 2019

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 Feb 7, 2019
@stale stale bot closed this as completed Feb 14, 2019
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 Confirmed Salt engineer has confirmed bug/feature - often including a MCVE Execution-Module P4 Priority 4 Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around stale
Projects
None yet
Development

No branches or pull requests

4 participants