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

Fix broken /admin/background-tasks web UI when using Sentinel #670

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NeodymiumFerBore
Copy link

@NeodymiumFerBore NeodymiumFerBore commented Sep 1, 2024

An attempt to fix #642.

Bug recap

When using Sentinel, in get_scheduler_statistics function, queue.connection.connection_pool.connection_kwargs does not have a host key, making the function to raise a KeyError exception when it tries to define conn_key based on connection['host']. This makes the /admin/background-tasks page to return a 500 error, making it unusable.

What does this fix do

This PR fixes this by building conn_key from all sentinels host:port pairs.

With this fix, a scheduler configured with Sentinel appears like this (with mymaster being the Sentinel Service, and 0 the configured db index for this scheduler):

Sentinel(sentinel-1:26379,sentinel-2:26379,sentinel-3:26379)://mymaster/0

django-rq-fixed-admin-bg-tasks-sentinel

If you don't agree with this syntax, please let me know and I change it.

Alternative solution

An alternative solution would be to build the conn_key from the current Sentinel master for the given service, but I'm not sure what you prefer. It would make the code a bit easier to read, and would make the resulting string in the UI much shorter. But it's less clear about the config used for this scheduler.

NeodymiumFerBore/django-rq#2 implements this solution, if you want to take a look...

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

Successfully merging this pull request may close these issues.

Sentinel support broken since 2.9.0
1 participant