redbeat icon indicating copy to clipboard operation
redbeat copied to clipboard

celery-redbeat 2.3.2 breaks redis-sentinel mode with retry_period

Open rainsville opened this issue 1 year ago • 1 comments

Description

celery-redbeat 2.3.2 (specifically https://github.com/sibson/redbeat/pull/267) has introduced a breaking change when using redis-sentinel with a retry_period defined.

Details

Configuration:

redbeat_redis_url = "redis-sentinel"

redbeat_redis_options = {
    "sentinels": [
        (
            "ADDRESS",
            1234,
        )
    ],
    "service_name": "my-service-name",
    "retry_period": 30,
}

Error:

>       return getattr(app, REDBEAT_REDIS_KEY)
AttributeError: 'Celery' object has no attribute 'redbeat_redis'

Cause

https://github.com/sibson/redbeat/blob/main/redbeat/schedulers.py#L170 is responsible for setting the REDBEAT_REDIS_KEY when using the redis-sentinel mode. However, the if statement https://github.com/sibson/redbeat/blob/main/redbeat/schedulers.py#L163 evaluates to False, so no REDBEAT_REDIS_KEY attribute is set on the app. This is because getattr(app, REDBEAT_SENTINEL_KEY) is not an instance of Sentinel, as when a retry_period is specified, the type of the connection is RetryingConnection (https://github.com/sibson/redbeat/blob/main/redbeat/schedulers.py#L179)

rainsville avatar Mar 07 '25 15:03 rainsville

Same here 👍

man4red avatar Mar 22 '25 20:03 man4red