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

Redis Transport: Small improvements of SentinelChannel #1253

Merged
merged 2 commits into from
Sep 24, 2020

Conversation

matusvalo
Copy link
Member

@matusvalo matusvalo commented Sep 24, 2020

This PR contains 2 small improvements of SentinelChannel:

  1. Sentinel connection string now supports default port 26379:

BEFORE:

>>> import kombu
>>> c = kombu.Connection('sentinel://localhost', transport_options={'master_name': 'mymaster'})
>>>
>>> c.connect()
Traceback (most recent call last):
  // STACKTRACE OMITTED
  File "/home/environments/kombu/lib/python3.7/site-packages/redis/connection.py", line 502, in __init__
    self.port = int(port)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

AFTER

>>> import kombu
>>> c = kombu.Connection('sentinel://localhost', transport_options={'master_name': 'mymaster'})
>>>
>>> c.connect()
  1. Connection with Sentinel connection string missing master_name transport option now raises ValueError with information about missing parameter:

BEFORE:

>>> import kombu
>>> c = kombu.Connection('sentinel://localhost:26379')
>>>
>>> c.connect()
Traceback (most recent call last):
  // STACKTRACE OMITTED
  File "/home/environments/kombu/lib/python3.7/site-packages/redis/sentinel.py", line 212, in discover_master
    raise MasterNotFoundError("No master found for %r" % (service_name,))
redis.sentinel.MasterNotFoundError: No master found for None

AFTER

>>> import kombu
>>> c = kombu.Connection('sentinel://localhost:26379')
>>>
>>> c.connect()
Traceback (most recent call last):
  // STACKTRACE OMITTED
  File "/home/dev/kombu/kombu/transport/redis.py", line 1154, in _sentinel_managed_pool
    "'master_name' transport option must be specified."
ValueError: 'master_name' transport option must be specified.

Copy link
Member

@thedrow thedrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@thedrow thedrow merged commit faa1d86 into celery:master Sep 24, 2020
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.

2 participants