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
Merged

Redis sdb mod #48239

merged 4 commits into from Jun 26, 2018

Conversation

@mirceaulinic
Copy link
Member

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

Copy link
Contributor

@gtmanfred gtmanfred 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)
Copy link
Contributor

@gtmanfred gtmanfred Jun 21, 2018

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)

Copy link
Member Author

@mirceaulinic mirceaulinic Jun 21, 2018

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?

Copy link
Contributor

@gtmanfred gtmanfred Jun 21, 2018

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

Copy link
Member Author

@mirceaulinic mirceaulinic Jun 21, 2018

Yes, good catch, should use StrictRedis indeed.

Copy link
Member Author

@mirceaulinic mirceaulinic Jun 26, 2018

Pushed 3f17add to solve this.

Copy link
Contributor

@rallytime rallytime 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
Copy link
Contributor

@rallytime rallytime Jun 26, 2018

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

Copy link
Member Author

@mirceaulinic mirceaulinic Jun 26, 2018

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
Copy link
Contributor

@rallytime rallytime commented Jun 26, 2018

Thanks @mirceaulinic!

@rallytime rallytime merged commit 7b4972a into saltstack:develop Jun 26, 2018
5 of 10 checks passed
5 of 10 checks passed
@s0undt3ch
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[bot]
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
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants