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

Redis sdb mod #48239

Merged
merged 4 commits into from Jun 26, 2018

Conversation

Projects
None yet
3 participants
@mirceaulinic
Copy link
Member

commented Jun 21, 2018

What does this PR do?

Adds an SDB module for Redis.

Tests written?

No - but happy to provide: I'm unsure how to mock a connection to a Redis server, without having the Redis server.

Commits signed with GPG?

No

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@gtmanfred
Copy link
Contributor

left a comment

Just a small change to use the already written redis module, instead of importing redis here.

Thanks,
Daniel

return False
redis_kwargs = profile.copy()
redis_kwargs.pop('driver')
redis_conn = redis.Redis(**redis_kwargs)

This comment has been minimized.

Copy link
@gtmanfred

gtmanfred Jun 21, 2018

Contributor

Fyi, we pack the minion modules into sdb.

https://github.com/saltstack/salt/blob/develop/salt/loader.py#L892

So, you should just be able to do __salt__['redis.set'](key, value, **redis_kwargs)

This comment has been minimized.

Copy link
@mirceaulinic

mirceaulinic Jun 21, 2018

Author Member

I tried on 2017.7 and it doesn't work like that. Did that change in 2018.3?

Either way, the Redis module only accepts host, password, port, and db as arguments, while there are many more available (and with the code I proposed we don't impose any restriction - some of them are very important!) - see https://redis-py.readthedocs.io/en/latest/#contents. What do you think?

This comment has been minimized.

Copy link
@gtmanfred

gtmanfred Jun 21, 2018

Contributor

OK, those should also be added to the redis module, but we don't have to do that now, but this should still use the StrictRedis class

This comment has been minimized.

Copy link
@mirceaulinic

mirceaulinic Jun 21, 2018

Author Member

Yes, good catch, should use StrictRedis indeed.

This comment has been minimized.

Copy link
@mirceaulinic

mirceaulinic Jun 26, 2018

Author Member

Pushed 3f17add to solve this.

@rallytime
Copy link
Contributor

left a comment

One small request from me. :)

This could use a .. versionadded:: Fluorine tag as well.

For option details see: https://redis-py.readthedocs.io/en/latest/.
'''
from __future__ import absolute_import

This comment has been minimized.

Copy link
@rallytime

rallytime Jun 26, 2018

Contributor

We also need to import print_function and unicode_literals here for PY3 compatibility.

This comment has been minimized.

Copy link
@mirceaulinic

mirceaulinic Jun 26, 2018

Author Member

Good points - added: 30cd544

Regarding print_function and unicode_literals: I've seen this has been added across all the modules, and I'm afraid I didn't understand that - could you please explain why is print_function (for example) needed although the module doesn't call the print() function? Thanks!

@rallytime

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2018

Thanks @mirceaulinic!

@rallytime rallytime merged commit 7b4972a into saltstack:develop Jun 26, 2018

5 of 10 checks passed

default Pull Requests » Salt PR - Main Build - PY2/PY3 #9768
Details
jenkins/PR/salt-pr-linode-ubuntu16-py3 Pull Requests » Salt PR - Linode Ubuntu16.04 - PY3 #11012 — ABORTED
Details
codeclimate 2 issues to fix
Details
jenkins/PR/salt-pr-linode-cent7-py3 Pull Requests » Salt PR - Linode CentOS 7 - PY3 #6042 — FAILURE
Details
jenkins/PR/salt-pr-rs-cent7-n Pull Requests » Salt PR - RS CentOS 7 #20095 — FAILURE
Details
WIP ready for review
Details
jenkins/PR/salt-pr-clone Pull Requests » Salt PR - Clone #26246 — SUCCESS
Details
jenkins/PR/salt-pr-docs-n Pull Requests » Salt PR - Docs #18293 — SUCCESS
Details
jenkins/PR/salt-pr-linode-ubuntu14-n Pull Requests » Salt PR - Linode Ubuntu14.04 #23970 — SUCCESS
Details
jenkins/PR/salt-pr-lint-n Pull Requests » Salt PR - Code Lint #22928 — SUCCESS
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.