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
Contributor

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch, should use StrictRedis indeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed 3f17add to solve this.

Copy link
Contributor

@rallytime rallytime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Thanks @mirceaulinic!

@rallytime rallytime merged commit 7b4972a into saltstack:develop Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants