enhancement celery configuration #22152

Closed
opened 2026-02-21 20:15:58 -05:00 by yindo · 1 comment
Owner

Originally created by @ruanimal on GitHub (Feb 9, 2026).

Originally assigned to: @ruanimal on GitHub.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Problems

1. Missing Redis Sentinel SSL Support: The current logic for determining if SSL options should be applied to the Celery broker only checks for redis:// and rediss:// protocols. Users using Redis Sentinel (sentinel://) with SSL find their SSL configurations are ignored.
2. Lack of Task Annotations Support: There is currently no way to specify Celery task annotations (e.g., for setting rate limits or other task-specific options) via the environment configuration.
3. Transport Options Inconsistency: The result_backend_transport_options are not explicitly set to match broker_transport_options. This can lead to issues where the result backend fails to connect if specific transport options (like SSL) are required but only applied to the broker.

Proposed Changes

1. Update SSL Option Logic: Modify api/extensions/ext_celery.py to include sentinel:// whenever checking if the broker is Redis-based for SSL configuration purposes.
2. Add Task Annotations Configuration:
- Introduce CELERY_TASK_ANNOTATIONS in api/configs/middleware/__init__.py.
- Apply these annotations to the Celery app configuration in api/extensions/ext_celery.py.
3. Sync Transport Options: Explicitly set result_backend_transport_options to use the same values as broker_transport_options in the Celery app initialization when use redis backend.
4. Enhanced Testing: Add unit tests to verify that SSL options are correctly applied when using the sentinel:// protocol.

Benefits

  • Better Redis Sentinel Support: Enables secure SSL connections for deployments using Redis Sentinel.
  • Improved Flexibility: Allows administrators to set task-level overrides (like rate limits) through configuration files or environment variables.
  • Robustness: Ensures consistency between broker and result backend connection settings.

2. Additional context or comments

NOTE: Currently, the functions related to Celery Sentinel SSL are a bit complicated. Later, they will be addressed in a separate PR.

reference

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @ruanimal on GitHub (Feb 9, 2026). Originally assigned to: @ruanimal on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. #### Problems ~1. **Missing Redis Sentinel SSL Support**: The current logic for determining if SSL options should be applied to the Celery broker only checks for `redis://` and `rediss://` protocols. Users using Redis Sentinel (`sentinel://`) with SSL find their SSL configurations are ignored.~ 2. **Lack of Task Annotations Support**: There is currently no way to specify Celery task annotations (e.g., for setting rate limits or other task-specific options) via the environment configuration. 3. **Transport Options Inconsistency**: The `result_backend_transport_options` are not explicitly set to match `broker_transport_options`. This can lead to issues where the result backend fails to connect if specific transport options (like SSL) are required but only applied to the broker. #### Proposed Changes ~1. **Update SSL Option Logic**: Modify `api/extensions/ext_celery.py` to include `sentinel://` whenever checking if the broker is Redis-based for SSL configuration purposes.~ 2. **Add Task Annotations Configuration**: - Introduce `CELERY_TASK_ANNOTATIONS` in `api/configs/middleware/__init__.py`. - Apply these annotations to the Celery app configuration in `api/extensions/ext_celery.py`. 3. **Sync Transport Options**: Explicitly set `result_backend_transport_options` to use the same values as `broker_transport_options` in the Celery app initialization when use redis backend. 4. **Enhanced Testing**: Add unit tests to verify that SSL options are correctly applied when using the `sentinel://` protocol. #### Benefits - ~**Better Redis Sentinel Support**: Enables secure SSL connections for deployments using Redis Sentinel.~ - **Improved Flexibility**: Allows administrators to set task-level overrides (like rate limits) through configuration files or environment variables. - **Robustness**: Ensures consistency between broker and result backend connection settings. #### 2. Additional context or comments NOTE: Currently, the functions related to Celery Sentinel SSL are a bit complicated. Later, they will be addressed in a separate PR. reference - [celery task_annotations](https://docs.celeryq.dev/en/v5.6.0/userguide/configuration.html#std-setting-task_annotations) ### 3. Can you help us with this feature? - [x] I am interested in contributing to this feature.
yindo added the 💪 enhancement label 2026-02-21 20:15:58 -05:00
yindo closed this issue 2026-02-21 20:15:58 -05:00
Author
Owner

@ruanimal commented on GitHub (Feb 9, 2026):

Currently, the functions related to Celery Sentinel SSL are a bit complicated. Later, they will be addressed in a separate PR.

@ruanimal commented on GitHub (Feb 9, 2026): Currently, the functions related to Celery Sentinel SSL are a bit complicated. Later, they will be addressed in a separate PR.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#22152