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

result_backend setting supports rediss:// protocol URLs #4696

Merged

Conversation

remeika
Copy link
Contributor

@remeika remeika commented May 1, 2018

Implements support to configure a Redis + TLS connection to the result backend purely by using result_backend, rather than the setting redis_backend_use_ssl.

The fields within redis_backend_use_ssl are now configurable via URL parameters. This has two significant advantages:

  1. A settings file does not need to import the ssl package in order to declare redis_backend_use_ssl.cert_reqs. This allows more configuration to be pulled from the environment rather than committed as code.
  2. Projects that depend on celery do not need to expose an analogous setting to redis_backend_use_ssl; users can connect to Redis + TLS in dependent projects without any changes by maintainers.

Fixes #4695

@remeika
Copy link
Contributor Author

remeika commented May 1, 2018

@thedrow Done. Thanks, I had overlooked that part of the contribution docs.

@remeika remeika force-pushed the rediss-protocol-support-results-backend branch from de3f9c9 to 84c7053 Compare May 1, 2018 12:47
@codecov
Copy link

codecov bot commented May 1, 2018

Codecov Report

Merging #4696 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4696      +/-   ##
==========================================
+ Coverage    82.6%   82.62%   +0.02%     
==========================================
  Files         140      140              
  Lines       15868    15892      +24     
  Branches     1983     1989       +6     
==========================================
+ Hits        13107    13131      +24     
  Misses       2567     2567              
  Partials      194      194
Impacted Files Coverage Δ
celery/app/backends.py 59.37% <ø> (ø) ⬆️
celery/backends/redis.py 91.25% <100%> (+0.87%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c753d7...9c14f88. Read the comment docs.

@remeika
Copy link
Contributor Author

remeika commented May 3, 2018 via email

@thedrow thedrow merged commit ca172b4 into celery:master May 7, 2018
@archit
Copy link

archit commented Jun 18, 2018

How does one use this? I'm trying to use this in my Flask app, and I get this error ...


  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "./disruptor/routes.py", line 684, in celery_dummy
    answer.delay()
  File "/usr/local/lib/python3.6/site-packages/celery/app/task.py", line 408, in delay
    return self.apply_async(args, kwargs)
  File "/usr/local/lib/python3.6/site-packages/celery/app/task.py", line 535, in apply_async
    **options
  File "/usr/local/lib/python3.6/site-packages/celery/app/base.py", line 741, in send_task
    with self.producer_or_acquire(producer) as P:
  File "/usr/local/lib/python3.6/site-packages/celery/app/base.py", line 876, in producer_or_acquire
    producer, self.producer_pool.acquire, block=True,
  File "/usr/local/lib/python3.6/site-packages/celery/app/base.py", line 1246, in producer_pool
    return self.amqp.producer_pool
  File "/usr/local/lib/python3.6/site-packages/celery/app/amqp.py", line 612, in producer_pool
    self.app.connection_for_write()]
  File "/usr/local/lib/python3.6/site-packages/celery/app/base.py", line 773, in connection_for_write
    return self._connection(url or self.conf.broker_write_url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/celery/app/base.py", line 841, in _connection
    'broker_connection_timeout', connect_timeout
  File "/usr/local/lib/python3.6/site-packages/kombu/connection.py", line 179, in __init__
    if not get_transport_cls(transport).can_parse_url:
  File "/usr/local/lib/python3.6/site-packages/kombu/transport/__init__.py", line 83, in get_transport_cls
    _transport_cache[transport] = resolve_transport(transport)
  File "/usr/local/lib/python3.6/site-packages/kombu/transport/__init__.py", line 63, in resolve_transport
    transport, alt))
KeyError: 'No such transport: rediss.  Did you mean redis?'

Seems like there is some integration issue between this PR within celery and kombu.

@remeika
Copy link
Contributor Author

remeika commented Jun 18, 2018

@archit Please post the results of the following commands:

pip freeze | grep celery
pip freeze | grep kombu

@remeika remeika deleted the rediss-protocol-support-results-backend branch June 18, 2018 20:43
@archit
Copy link

archit commented Jun 18, 2018

@remeika here's the output from my setup...

[archit@ip-10-0-2-54 ~]$  sudo docker exec 3cb pip freeze | grep celery
celery==4.2.0
[archit@ip-10-0-2-54 ~]$  sudo docker exec 3cb pip freeze | grep kombu
kombu==4.2.1
[archit@ip-10-0-2-54 ~]$

@remeika
Copy link
Contributor Author

remeika commented Jun 19, 2018 via email

@georgepsarakis
Copy link
Contributor

@archit @remeika I believe the broker_use_ssl setting is the equivalent.

@archit
Copy link

archit commented Jun 19, 2018

@remeika @georgepsarakis oh ok, that makes sense. I'm using redis as a broker. I did not realize this was not for the broker. Thanks for clarifying.

@remeika
Copy link
Contributor Author

remeika commented Jun 19, 2018

@archit See here for why I added this feature to one but not the other.

Issue to add support for rediss:// URL protocol to broker_url is #4694. I am going to try to find time to work on it soon. But if you beat me to it, I'd be overjoyed 😃.

@archit
Copy link

archit commented Jun 20, 2018

@remeika haha, sure thing. Let me see if I can make some time. I will have to review some of the details in CONTRIBUTING.rst. Also I first have to get to make this work using broker_use_ssl, in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants