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

Unable to use Redis UNIX socket #5391

Closed
paulmenzel opened this issue Jun 25, 2022 · 2 comments
Closed

Unable to use Redis UNIX socket #5391

paulmenzel opened this issue Jun 25, 2022 · 2 comments
Labels
Milestone

Comments

@paulmenzel
Copy link

paulmenzel commented Jun 25, 2022

$ git log --no-decorate --oneline -1
b732cbe299 Remove trailing whitespace

I am trying to use Redis socket, but it looks like the Python components use different URL formats.

  1. The Python package redis uses the schemes redis://, rediss://, and unix://.

  2. The Python library limits uses:

    If the redis server is listening over a unix domain socket you can use redis+unix:///path/to/sock or redis+unix:///path/to/socket?db=n (for database n).

With

CELERY_BROKER = 'redis+unix:///project/indico/tmp/redis.sock?db=0'
REDIS_CACHE_URL = 'unix:///project/indico/tmp/redis.sock?virtual_host=1'

it fails:

Traceback (most recent call last):
  File "/project/indico/home/.local/bin/indico", line 33, in <module>
    sys.exit(load_entry_point('indico', 'console_scripts', 'indico')())
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/project/indico/home/.local/lib/python3.9/site-packages/flask/cli.py", line 579, in main
    return super().main(*args, **kwargs)
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/project/indico/home/.local/lib/python3.9/site-packages/flask/cli.py", line 426, in decorator
    with __ctx.ensure_object(ScriptInfo).load_app().app_context():
  File "/project/indico/home/.local/lib/python3.9/site-packages/flask/cli.py", line 382, in load_app
    app = self.create_app()
  File "/project/indico/home/src/indico/indico/cli/util.py", line 26, in _create_app
    return make_app()
  File "/project/indico/home/src/indico/indico/web/flask/app.py", line 416, in make_app
    limiter.init_app(app)
  File "/project/indico/home/.local/lib/python3.9/site-packages/flask_limiter/extension.py", line 311, in init_app
    storage_from_string(
  File "/project/indico/home/.local/lib/python3.9/site-packages/limits/storage/__init__.py", line 62, in storage_from_string
    raise ConfigurationError("unknown storage scheme : %s" % storage_string)
limits.errors.ConfigurationError: unknown storage scheme : unix:///project/indico/tmp/redis.sock?virtual_host=1

The other scheme causes:

Traceback (most recent call last):
  File "/project/indico/home/.local/bin/indico", line 33, in <module>
    sys.exit(load_entry_point('indico', 'console_scripts', 'indico')())
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/project/indico/home/.local/lib/python3.9/site-packages/flask/cli.py", line 579, in main
    return super().main(*args, **kwargs)
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/pkg/python-3.9.12-0/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/project/indico/home/.local/lib/python3.9/site-packages/flask/cli.py", line 426, in decorator
    with __ctx.ensure_object(ScriptInfo).load_app().app_context():
  File "/project/indico/home/.local/lib/python3.9/site-packages/flask/cli.py", line 382, in load_app
    app = self.create_app()
  File "/project/indico/home/src/indico/indico/cli/util.py", line 26, in _create_app
    return make_app()
  File "/project/indico/home/src/indico/indico/web/flask/app.py", line 406, in make_app
    cache.init_app(app)
  File "/project/indico/home/.local/lib/python3.9/site-packages/flask_caching/__init__.py", line 141, in init_app
    self._set_cache(app, config)  
  File "/project/indico/home/.local/lib/python3.9/site-packages/flask_caching/__init__.py", line 172, in _set_cache
    app.extensions["cache"][self] = cache_factory(
  File "/project/indico/home/src/indico/indico/core/cache.py", line 82, in factory
    kwargs['host'] = redis_from_url(config['CACHE_REDIS_URL'], socket_timeout=1)
  File "/project/indico/home/.local/lib/python3.9/site-packages/redis/utils.py", line 28, in from_url
    return Redis.from_url(url, **kwargs)
  File "/project/indico/home/.local/lib/python3.9/site-packages/redis/client.py", line 896, in from_url
    connection_pool = ConnectionPool.from_url(url, **kwargs)
  File "/project/indico/home/.local/lib/python3.9/site-packages/redis/connection.py", line 1271, in from_url
    url_options = parse_url(url)  
  File "/project/indico/home/.local/lib/python3.9/site-packages/redis/connection.py", line 1208, in parse_url
    raise ValueError(
ValueError: Redis URL must specify one of the following schemes (redis://, rediss://, unix://)
@ThiefMaster
Copy link
Member

oops... let's see if the limits author is willing to add compatibility with the redis format...

@ThiefMaster ThiefMaster added this to the v3.2 milestone Jul 8, 2022
elsbethe pushed a commit to elsbethe/indico that referenced this issue Jul 8, 2022
@paulmenzel
Copy link
Author

What is the correct format now?

CELERY_BROKER = 'redis+unix:///project/indico/tmp/redis.sock?db=0'
REDIS_CACHE_URL = 'unix:///project/indico/tmp/redis.sock?virtual_host=1'

results in:

Unrecoverable error: ValueError("invalid literal for int() with base 10: 'project/indico/tmp/redis.sock'")

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

No branches or pull requests

2 participants