-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Add support for TLS connections to redis #2357
Conversation
c0edb2c
to
2129eb7
Compare
Tests seem to be failing on Postgres related queries which are not related to my changes. Unsure if this is something I can fix |
tests/__init__.py
Outdated
os.environ['REDASH_CELERY_BROKER'] = os.environ.get('REDASH_REDIS_URL', "redis://localhost:6379/0").replace("/5", "/6") | ||
PYTEST_ENABLE_REDIS_CLEANUP = ast.literal_eval(os.environ.get('PYTEST_ENABLE_REDIS_CLEANUP', 'True')) | ||
if PYTEST_ENABLE_REDIS_CLEANUP: | ||
os.environ['REDASH_REDIS_URL'] = os.environ.get('REDASH_REDIS_URL', "redis://localhost:6379/0").replace("/0", "/5") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty useless when just using it locally
There appears to be more to it, celery is not picking up any SSL options. The app starts but on login, celery/kombu throws a 500 with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding this, supporting rediss://
can be nice.
The tests aren't failing on "Postgres related queries" but on Redis calls (check the stacktrace). I guess it's because of the use of Redis
instead of StrictRedis
(see comments).
If Celery really doesn't support this, then it's a blocker to adopting this... and we need to wait for Celery to support it or check if we can pass a Redis client to it instead of connection details.
And one last thing -- please try to keep the scope of each pull request limited to one thing. Makes reviewing easier and also merging faster.
redash/__init__.py
Outdated
r = redis.StrictRedis(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_password) | ||
|
||
return r | ||
return redis.from_url(settings.REDIS_URL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to use StrictRedis.from_url
, because redis.from_url
returns a Redis
object instead of StrictRedis
.
docker-compose.yml
Outdated
restart: unless-stopped | ||
postgres: | ||
image: postgres:9.5.6-alpine | ||
ports: | ||
- 5432:5432 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While exposing the ports is useful, I don't think we should include this in the default configuration as it might conflict with other configurations the user might have.
README.md
Outdated
$ npm install | ||
$ npm run build | ||
$ pytest tests | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't belong in the README, but in the developer docs. Also there is a much simpler method to run the tests (see Running Tests
here).
tests/__init__.py
Outdated
os.environ['REDASH_REDIS_URL'] = os.environ.get('REDASH_REDIS_URL', "redis://localhost:6379/0").replace("/0", "/5") | ||
# Use different url for Celery to avoid DB being cleaned up: | ||
os.environ['REDASH_CELERY_BROKER'] = os.environ.get('REDASH_REDIS_URL', "redis://localhost:6379/0").replace("/5", "/6") | ||
PYTEST_ENABLE_REDIS_CLEANUP = ast.literal_eval(os.environ.get('PYTEST_ENABLE_REDIS_CLEANUP', 'True')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use true
and redash.settings.parse_boolean
to be consistent with other env variables we have.
But I don't see the value in adding this setting. It is useful locally, because when you use the same Redis server both for tests and development it's annoying (and causes issues) when Redis gets flushed.
The database replacement method here can be more elaborate, but because it's always possible to override with env variables, I figured we could just aim at the default.
Im stuck on the celery portion still for sure. It does support it
However it doesnt seem to support the rediss:// portion |
I went ahead and removed the docs/irrelevant changes @arikfr , its down to the TLS portion only |
I've added this capability in our fork (from the latest master as of 3/30/19) via narratorai#1 I'd be happy to add more tests, docs, etc and open up a PR upstream here -- would love any feedback! |
The current method does not allow secure redis
rediss://
After this change: