Add support for checking broker connections using new settings.
Review Request #15402 — Created Oct. 16, 2026 and updated
This introduces a
check_connection()method on broker backends, which
takes saved or pending settings and checks that the broker can be
reached with them.This will be used for the upcoming configuration form, and may be used
for server health checks later.The Local Broker checks the writability of either the specified local
queue path or the common directory within the sitedir's data directory.
Due to the nature of local brokers, it's entirely possible that this
could succeed on the server performing the check but fail on a
separate misconfigured server. Still, best attempt.Celery-based brokers will set up a temporary Celery instance using the
settings and then make a quick connection attempt to see if it succeeds.This does make one path change for the Local Broker. Previously, queues
were stored in<datadir>/<hostname>/local-queue. Now it's
<datadir>/local-queue/<hostname>. This provides a better path to check
(especially for shared site directories) and also gives a stable symlink
point.
Unit tests pass.
Tested local broker validation with the upcoming admin form changes.
| Summary | ID |
|---|---|
| 869993562f9b4910e1b28a5a5702cf588b925dd0 |
| Description | From | Last Updated |
|---|---|---|
|
If something in the typed path is a +x file, this loop will find it and say we're finished, but … |
|
|
|
If connection_for_write raises, the celery app could leak. How about: app = self._build_celery(broker_settings=broker_settings) try: conn = app.connection_for_write(connect_timeout=timeout_secs) try: conn.ensure_connection(max_retries=0, timeout=timeout_secs) … |
|
|
|
This (and the other unwritable tests) will fail if we're running tests in a docker environment. Can we skip if … |
|
-
-
If something in the typed path is a +x file, this loop will find it and say we're finished, but then makedirs will fail. Can we do another
if not os.path.isdir(check_path): raise ValueErrorafter the loop? -
If
connection_for_writeraises, the celery app could leak. How about:app = self._build_celery(broker_settings=broker_settings) try: conn = app.connection_for_write(connect_timeout=timeout_secs) try: conn.ensure_connection(max_retries=0, timeout=timeout_secs) finally: conn.release() finally: app.close() -
This (and the other unwritable tests) will fail if we're running tests in a docker environment. Can we skip if
os.geteuid() == 0?
- Change Summary:
-
- Added protection against paths where a component is a file.
- Added handling for
connection_for_write()raising an exception. - Unit tests that need permission checks are skipped if run as root.
- Commits:
-
Summary ID c6d049b102a3275755f87f99664c157155c3ca36 869993562f9b4910e1b28a5a5702cf588b925dd0