salt icon indicating copy to clipboard operation
salt copied to clipboard

Salt Future Returner

Open mostafahussein opened this issue 11 years ago • 25 comments

I can see two pages on the documentation about mongo_returner and mongo_future_returner

How can i use mongo_future_returner instead of mongo_returner ? there is nothing in the documentation explaining such case.

I have tried --return mongo_future_return but its not working at all

mostafahussein avatar Sep 15 '15 07:09 mostafahussein

Are you running a version of Salt that includes the returner? If you can run salt --versions-report and paste in the results, we can help you determine if it's in the version that you're running.

cachedout avatar Sep 15 '15 14:09 cachedout

@cachedout it was 2015.5.5, and currently i am using fedora 21 , and i have enabled saltstack-repo which made for rhel7 on my fedora 21 , then i have updated salt thorugh this repo to 2015.8.0 then when i tried the sudo salt-call test.ping --return mongo -ldebug i got nothing saved to mongodb

here is the current version report:

Salt Version:
           Salt: 2015.8.0

Dependency Versions:
         Jinja2: 2.7.3
       M2Crypto: 0.21.1
           Mako: 1.0.0
         PyYAML: 3.11
          PyZMQ: 14.3.1
         Python: 2.7.8 (default, Jul  5 2015, 14:16:16)
           RAET: 0.6.3
        Tornado: 4.2.1
            ZMQ: 3.2.5
           cffi: 1.2.1
       cherrypy: 3.7.0
       dateutil: 2.4.2
          gitdb: 0.6.4
      gitpython: Not Installed
          ioflo: 1.3.9
        libnacl: 1.4.3
   msgpack-pure: 0.1.3
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: 0.9.0
        timelib: 0.2.4

System Versions:
           dist: fedora 21 Twenty One
        machine: x86_64
        release: 4.1.6-100.fc21.x86_64
         system: Fedora 21 Twenty One

And here is the debug result:

➜  ~ sudo salt-call test.ping --return mongo -ldebug
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Configuration file path: /etc/salt/minion
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'minion_01', 'tcp://127.0.0.1:4506')
[DEBUG   ] Generated random reconnect delay between '1000ms' and '11000ms' (10871)
[DEBUG   ] Setting zmq_reconnect_ivl to '10871ms'
[DEBUG   ] Setting zmq_reconnect_ivl_max to '11000ms'
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'minion_01', 'tcp://127.0.0.1:4506', 'aes')
[DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'minion_01', 'tcp://127.0.0.1:4506')
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'minion_01', 'tcp://127.0.0.1:4506', 'clear')
[DEBUG   ] Decrypting the current master AES key
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded test.ping
[DEBUG   ] LazyLoaded mongo.returner
[DEBUG   ] LazyLoaded config.option
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'minion_01', 'tcp://127.0.0.1:4506', 'aes')
[DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'minion_01', 'tcp://127.0.0.1:4506')
[DEBUG   ] LazyLoaded nested.output
local:
    True

It was working before i added saltstack-repo to fedora 21 , is this the cause ?! , i thought it should be compatible with fedora as its a saltstack repo for centos/rhel 7

What Can i do ?

mostafahussein avatar Sep 15 '15 16:09 mostafahussein

I have the same problem on CentOS , there is nothing returned to mongodb however it says LazyLoaded mongo.returner, versions-report:

Salt Version:
           Salt: 2015.8.0

Dependency Versions:
         Jinja2: 2.2.1
       M2Crypto: 0.20.2
           Mako: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.3.1
         Python: 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 3.2.2
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.4.1
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: centos 6.7 Final
        machine: x86_64
        release: 2.6.32-504.16.2.el6.x86_64
         system: CentOS 6.7 Final

mostafahussein avatar Sep 16 '15 03:09 mostafahussein

when i downgraded to 2015.5.5 i was able to return to mongodb but not with the future returner

mostafahussein avatar Sep 16 '15 05:09 mostafahussein

Could anyone change the label to Bug ? I don't see any errors on my configuration to make mongodb returner not work with the latest version of salt ? what was the change between 2015.8 and 2015.5.5 ?

Blank password is a problem ?! I cannot find any explanation that causing mongodb returner not to work :/

mostafahussein avatar Sep 17 '15 01:09 mostafahussein

@sh3llsh0ck, so you are able to get the mongo returner to work with 2015.5.5 and not 2015.8.0 and you cannot get the mongo_future returner to work on either? Is it possible for you to post your configs?

jfindlay avatar Sep 17 '15 17:09 jfindlay

@jfindlay , its a very basic steps , first i have installed salt for my local host as 2015.5.5 then tested the mongodb returner with a basic configuration on minion with blank password and blank username:

mongo.db: saltdb
mongo.host: localhost
mongo.user: ''
mongo.password: ''
mongo.port: 27017

then executing this command salt-call grains.items --return mongo , everything works correctly, then after searching on google i have found that future returner will have a better json structure easier to handle like making the jid as value not as key. i didn't know how should i make it work ? then i have added rhel repo to my fedora in order to update salt to the latest stable version 2015.8.0 , then i tried the same command and i got nothing saved to the database , but if i downgraded salt the returner will work again , i thought it could be an issue with fedora specifically so i tried the same steps on centos with latest version of salt but i cannot save to mongodb also

mostafahussein avatar Sep 17 '15 23:09 mostafahussein

@sh3llsh0ck, thanks for the report. @rhealitycheck, @mecarus, do you have any ideas on this one?

jfindlay avatar Sep 18 '15 18:09 jfindlay

I'm taking a look, I've used the future returner with 2015.5 so I'm surprised it isn't working but I haven't tried 2015.8 so I'm not sure what's going on yet.

rhealitycheck avatar Sep 18 '15 19:09 rhealitycheck

@rhealitycheck if there is something i can do, i will be glad to help! but i cannot find any logs that could be helpful on this issue, also there is no errors so i can determine which part of salt's code that responsible for this, is there any debugging steps that you will follow ?!

mostafahussein avatar Sep 18 '15 19:09 mostafahussein

There's a bug depending on your pymongo version it's checking for versions > 2.3 because the way you connect is different. But it fails if there are additional numbers ie 3.0.3 will fail because python can't convert to a float. I should have a fix in a day or so, I just need some time to test. Also it doesn't use the mongo_return ever, it defaults to mongo_future_return. You can see this if you have debug set on your salt master and look at the logs.

I can see it here:

2015-09-18 15:25:24,288 [salt.master                                 ][CRITICAL][17850] The specified returner threw a stack trace:
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/master.py", line 2078, in _prep_pub
    self.mminion.returners[fstr](clear_load['jid'], clear_load)
  File "/usr/lib/python2.6/site-packages/salt/returners/mongo_future_return.py", line 182, in save_load
    conn, mdb = _get_conn(ret=None)
  File "/usr/lib/python2.6/site-packages/salt/returners/mongo_future_return.py", line 134, in _get_conn
    if float(version) > 2.3:
ValueError: invalid literal for float(): 3.0.3

rhealitycheck avatar Sep 18 '15 21:09 rhealitycheck

@jfindlay is there a way to link a bugfix back to this issue? i'm submitting a fix now that should take care of the pymongo version issue.

rhealitycheck avatar Sep 21 '15 20:09 rhealitycheck

@sh3llsh0ck fwiw you can get the returner to return to mongo if you use pymongo version 3.0. anything with additional digits ie 3.0.3 will not return. also saltstack will not install pymongo for you, you need to ensure you have that on your master an any minions to ensure that any returns are able to be processed.

@jfindlay There's an additional bug I've found with serializing Mongo's default object id but as the serialization is done outside of this returner that may take longer for me to troubleshoot.

rhealitycheck avatar Sep 21 '15 20:09 rhealitycheck

@rhealitycheck yes i have pymongo installed on minion but version is 2.3.x i think. And i have commented the if condition's line then i found the returner worked. so yes my issue because the float()

For the salt master part should i install pymongo on master do i can use the returner with salt <minion_name> test.pinh --return mongo ? And what about the configuration in this case i think it shoulf be on master also . Am i right ? Anyway i will test the returner from master again as i think the last time i tried it from master it wasn't work.

For the mongo's default object id can it be anything else instead the current state ? Maybe i could be aut incremental integer ?

mostafahussein avatar Sep 21 '15 21:09 mostafahussein

And please could explain the second bug that you have found ?

mostafahussein avatar Sep 21 '15 21:09 mostafahussein

@sh3llsh0ck you shouldn't comment that line out because it helps identify how you connect to mongo. This is actually relevant to what version of pymongo you are using and what version of mongodb you are using. It would be better to either modify the file to handle these cases or to install a version without the extra digits.

Second, you can change the default object id however since the minions can return data simultaneously there isn't a good way to ensure uniqueness. The reason that mongo uses the object id the way they do is to ensure uniqueness for each document inserted, this is a fundamental database concept and while you can ignore it, it's not wise to do so. The issue I found is that salt is using msgpack to serialize returns but it cannot handle an arbitrary binary string which is what it thinks the object id is. I'm looking into how to get around this.

rhealitycheck avatar Sep 21 '15 21:09 rhealitycheck

Second bug fixed as well as per my latest PR

rhealitycheck avatar Sep 23 '15 18:09 rhealitycheck

Thanks for your work on this @rhealitycheck.

jfindlay avatar Sep 23 '15 22:09 jfindlay

this issue should be resolved, is there some criteria to close an issue/bug?

rhealitycheck avatar Sep 28 '15 16:09 rhealitycheck

@rhealitycheck, normally we give at least the original reporter an opportunity to verify, which in this case is @mostafahussein.

jfindlay avatar Sep 28 '15 19:09 jfindlay