【问题标题】:Celery Flower returning 500s on Broker Stats with Redis and SSL使用 Redis 和 SSL 在 Broker Stats 上返回 500 的 Celery Flower
【发布时间】:2021-04-03 04:57:55
【问题描述】:

我刚刚安装了芹菜花。

它非常适合向我展示实时任务、处理它们的队列、cpu 使用率和处理时间。

我还想访问代理页面,以便监控队列长度。

我遇到的问题是 SSL。

代理页面返回 500。查看日志,我看到以下堆栈跟踪。

2020-12-24T21:19:21.828079+00:00 app[web.1]: [W 201224 21:19:21 connection:255] Secure redis scheme specified (rediss) with no ssl options, defaulting to insecure SSL behaviour.
2020-12-24T21:19:21.854471+00:00 app[web.1]: [W 201224 21:19:21 connection:255] Secure redis scheme specified (rediss) with no ssl options, defaulting to insecure SSL behaviour.
2020-12-24T21:19:21.878474+00:00 app[web.1]: [E 201224 21:19:21 web:1793] Uncaught exception GET /broker (...)
2020-12-24T21:19:21.878479+00:00 app[web.1]: HTTPServerRequest(protocol='http', host='...herokuapp.com', method='GET', uri='/broker', version='HTTP/1.1', remote_ip='...')
2020-12-24T21:19:21.878480+00:00 app[web.1]: Traceback (most recent call last):
2020-12-24T21:19:21.878481+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/tornado/web.py", line 1704, in _execute
2020-12-24T21:19:21.878481+00:00 app[web.1]: result = await result
2020-12-24T21:19:21.878482+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/tornado/gen.py", line 234, in wrapper
2020-12-24T21:19:21.878482+00:00 app[web.1]: yielded = ctx_run(next, result)
2020-12-24T21:19:21.878482+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/tornado/gen.py", line 162, in _fake_ctx_run
2020-12-24T21:19:21.878483+00:00 app[web.1]: return f(*args, **kw)
2020-12-24T21:19:21.878483+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flower/views/broker.py", line 31, in get
2020-12-24T21:19:21.878485+00:00 app[web.1]: http_api=http_api, broker_options=broker_options, broker_use_ssl=broker_use_ssl)
2020-12-24T21:19:21.878485+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flower/utils/broker.py", line 237, in __new__
2020-12-24T21:19:21.878486+00:00 app[web.1]: return RedisSsl(broker_url, *args, **kwargs)
2020-12-24T21:19:21.878486+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flower/utils/broker.py", line 220, in __init__
2020-12-24T21:19:21.878486+00:00 app[web.1]: super(RedisSsl, self).__init__(broker_url, *args, **kwargs)
2020-12-24T21:19:21.878487+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flower/utils/broker.py", line 134, in __init__
2020-12-24T21:19:21.878487+00:00 app[web.1]: self.redis = self._get_redis_client()
2020-12-24T21:19:21.878488+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flower/utils/broker.py", line 155, in _get_redis_client
2020-12-24T21:19:21.878488+00:00 app[web.1]: return redis.Redis(**self._get_redis_client_args())
2020-12-24T21:19:21.878489+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flower/utils/broker.py", line 225, in _get_redis_client_args
2020-12-24T21:19:21.878489+00:00 app[web.1]: client_args.update(self.broker_use_ssl)
2020-12-24T21:19:21.878554+00:00 app[web.1]: TypeError: 'NoneType' object is not iterable
2020-12-24T21:19:21.881667+00:00 app[web.1]: [W 201224 21:19:21 connection:255] Secure redis scheme specified (rediss) with no ssl options, defaulting to insecure SSL behaviour.

看起来我需要以某种方式将证书传递给broker_use_ssl,但我不确定在哪里或如何。

这一切都部署在 Heroku 上。 redis URL 是我的生产应用程序中的内容,flower 在单独的应用程序中。

在芹菜上我有{"ssl_cert_reqs": ssl.CERT_NONE}

部署在heroku上的花看起来像

requirements.txt如下

celery==4.4.4
future==0.18.2
flower==0.9.7 
redis==3.5.3

然后是我尝试传入 ssl.CERT_NONE 的 Procfile,它返回 0。它不起作用。

web: flower --port=$PORT --broker=$BROKER_URL --basic_auth=$FLOWER_BASIC_AUTH --broker_use_ssl={"ssl_cert_reqs": 0}

谁能解释一下如何设置这些配置选项?

谢谢

【问题讨论】:

    标签: python heroku redis celery flower


    【解决方案1】:

    似乎与broker_use_ssl 相关的修复是两天前的mergedmaster。不确定它是否只是改进或错误修复。有一个相关问题here。请注意,最新版本尚未包含此修复程序(4 天前发布)。

    无论如何,您可以尝试以下方法:

    1. 您传递--broker_use_ssl 值的方式可能需要转义引号,例如:--broker_use_ssl={\"ssl_cert_reqs\": 0}--broker_use_ssl="{\"ssl_cert_reqs\": 0}"
    2. 尝试通过configuration file 而不是命令行传递您的设置,例如:flower --conf=celeryconfig.py - 这样您就不需要处理转义,您可以像以前一样设置值 ({"ssl_cert_reqs": 0}) .
    3. 使用master 分支查看最后一次提交是否解决了您的问题。

    祝你好运!

    【讨论】:

    • 感谢您,这无疑将我推向了正确的方向。转义引号对我不起作用,因此我尝试添加配置文件,但遇到导入错误问题。 celery.utils.imports.NotAPackage: Error: Module 'celeryconfig.py' doesn't exist, or it's not a valid Python module name. 那里有任何方向,我尝试添加一个 init.py 文件,但没有成功?
    • @hancho 你试过完整路径吗? /path/to/celeryconfig.py
    猜你喜欢
    • 2014-05-02
    • 2013-04-13
    • 1970-01-01
    • 2020-08-11
    • 2021-06-21
    • 1970-01-01
    • 2020-01-12
    • 1970-01-01
    • 2017-07-25
    相关资源
    最近更新 更多