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

StrictRedis() needs to be used when redis has a password #17

Closed
rberlind opened this issue Nov 11, 2017 · 1 comment
Closed

StrictRedis() needs to be used when redis has a password #17

rberlind opened this issue Nov 11, 2017 · 1 comment

Comments

@rberlind
Copy link
Contributor

rberlind commented Nov 11, 2017

I set a password on my redis database by adding command: ["redis-server"] and args = ["--requirepass " ] to the azure-vote-back container specification in my copy of azure-vote-all-in-one-redis.yml. I was able to validate with redis-cli AUTH on that container that the password was really set.

I also added the extra environment variable, REDIS_PWD, that was referenced in main.py in the azure-vote-front container and set it to the same password.

However, the azure-vote-front app could not connect to the redis database. It gave the error: "redis.exceptions.ResponseError: NOAUTH Authentication required."

But when I used kubectl exec cats-and-dogs-front -i -t -- bash to access the container and used apt-get update and apt-get install redis-tools and then used redis-cli against the correct host and port, I was able to connect. I was also able to run the AUTH command and authenticate. Additionally, I could see that REDIS_PWD was set with the correct password by running env | grep REDIS.

My conclusion was that the redis password was being set correctly both in the front and back apps and that I did not have a connectivity issue between the containers themselves (since redis-cli worked). So, I concluded that something must be wrong with the python code.

I researched the redis-py module being used and found docs at https://redis-py.readthedocs.io/en/latest/ which suggested that redis.Redis() is provided for backwards compatibility with older versions of redis-py and that redis.StrictRedis() is preferred.

So, I changed the code to use redis.StrictRedis instead of redis.Redis when the REDIS_PWD environment variable is set.

I built my own docker image at rberlind/azure-vote-front:redis-pwd and modified the yml file to use that image. Everything then worked.

I will submit a pull request.

@neilpeterson
Copy link
Contributor

I've merged the PR - thanks again.

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

No branches or pull requests

2 participants