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

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...

@moonrail
Copy link

Tested in context of NetBox 4.1.3 and am able to confirm that this fixes issue #642 and adds back Sentinel support.

Thank you @NeodymiumFerBore 👍

@NeodymiumFerBore
Copy link
Author

@moonrail PR #671 got merged and fixes the same issue, with cleaner code. Can you test again with #671 ?
This PR should get closed shortly. If you confirm that #671 does the job, I'll close it myself.
Thank you for your feedback!

@moonrail
Copy link

@NeodymiumFerBore PR #671 fixed it for me as well 👍

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
2 participants