Skip to content

Add RabbitMQ Service to Docker Compose Configuration #5439

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

Merged
merged 11 commits into from
Sep 2, 2024

Conversation

akshat5302
Copy link
Member

@akshat5302 akshat5302 commented Aug 27, 2024

Summary:
This PR transitions our application's task queuing system from Redis to RabbitMQ, aiming for improved reliability, scalability, and more robust messaging features.

Key Changes:

  • Docker Compose: Added RabbitMQ service (plane-mq) with necessary environment configurations
    and volumes.
  • Django Celery: Updated configurations to use RabbitMQ as the broker for Celery tasks.
  • Task Queuing: Reworked queuing for activities, notifications, and email notifications to utilize RabbitMQ for more efficient processing.

Why RabbitMQ? We switched to RabbitMQ because it’s better suited for handling complex messaging needs as our application grows. Unlike Redis, RabbitMQ is designed specifically as a message broker. This ensures our task handling and notifications are more efficient and scalable.

Summary by CodeRabbit

  • New Features

    • Integrated RabbitMQ messaging service into the application, enhancing message queuing and processing capabilities.
    • Added configuration options for RabbitMQ, allowing for customizable connection settings.
  • Bug Fixes

    • Removed outdated Redis configuration, ensuring the application now uses RabbitMQ as the primary messaging backend.
  • Documentation

    • Updated environment variable settings to include RabbitMQ parameters in configuration files.
  • Chores

    • Added new dependency for django-celery-results to improve task management and result storage.

Copy link
Contributor

coderabbitai bot commented Aug 27, 2024

Walkthrough

The changes introduce RabbitMQ configuration settings across multiple files, including environment variables for connection parameters and a new RabbitMQ service in Docker Compose files. The application now supports message queuing and processing through RabbitMQ, with corresponding adjustments in settings and dependencies to facilitate this integration.

Changes

Files Change Summary
.env.example, apiserver/.env.example, deploy/selfhost/variables.env Added new RabbitMQ-related environment variables: RABBITMQ_HOST, RABBITMQ_PORT, RABBITMQ_USER, RABBITMQ_PASSWORD, RABBITMQ_VHOST.
apiserver/plane/settings/common.py Introduced RabbitMQ connection settings, including AMQP_URL, and modified CELERY_BROKER_URL logic to prioritize RabbitMQ.
apiserver/requirements/base.txt Added dependency django-celery-results==2.5.1 for task result management with Celery.
deploy/selfhost/docker-compose.yml, docker-compose.yml, docker-compose-local.yml Added new RabbitMQ service plane-mq with configuration, including image, restart policy, and environment variables.
docker-compose-local.yml Removed existing network and volume definitions; reinstated them at the bottom while adding the RabbitMQ service.

Poem

🐰
In the garden of code, I hop with delight,
RabbitMQ's magic, a wondrous sight!
Messages dance, like leaves in the breeze,
Queuing and processing, oh, what a tease!
With each little change, our dreams take flight,
Together we build, in the soft moonlight.
🌙


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.
Early access features: disabled

We are currently testing the following features in early access:

  • Anthropic claude-3-5-sonnet for code reviews: Anthropic claims that the new Claude model has stronger code understanding and code generation capabilities than their previous models. Note: Our default code review model was also updated late last week. Please compare the quality of the reviews between the two models by toggling the early access feature.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues on the discussion post.

@akshat5302 akshat5302 closed this Aug 27, 2024
@akshat5302 akshat5302 changed the title Fix task queue Add RabbitMQ Service to Docker Compose Configuration Aug 27, 2024
@akshat5302 akshat5302 reopened this Aug 27, 2024
@sriramveeraghanta sriramveeraghanta marked this pull request as ready for review September 2, 2024 11:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (1)
apiserver/plane/settings/common.py (1)

270-270: Remove the trailing whitespace.

The static analysis tool has flagged a trailing whitespace in this line.

Apply this diff to remove the trailing whitespace:

-CELERY_BROKER_URL = f"amqp://{RABBITMQ_USER}:{RABBITMQ_PASSWORD}@{RABBITMQ_HOST}:{RABBITMQ_PORT}/{RABBITMQ_VHOST}" 
+CELERY_BROKER_URL = f"amqp://{RABBITMQ_USER}:{RABBITMQ_PASSWORD}@{RABBITMQ_HOST}:{RABBITMQ_PORT}/{RABBITMQ_VHOST}"
Tools
GitHub Check: Codacy Static Code Analysis

[notice] 270-270: apiserver/plane/settings/common.py#L270
Trailing whitespace

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0920969 and 4dd5540.

Files selected for processing (8)
  • .env.example (1 hunks)
  • apiserver/.env.example (1 hunks)
  • apiserver/plane/settings/common.py (1 hunks)
  • apiserver/requirements/base.txt (1 hunks)
  • deploy/selfhost/docker-compose.yml (6 hunks)
  • deploy/selfhost/variables.env (1 hunks)
  • docker-compose-local.yml (3 hunks)
  • docker-compose.yml (2 hunks)
Additional context used
yamllint
deploy/selfhost/docker-compose.yml

[error] 202-202: trailing spaces

(trailing-spaces)

GitHub Check: Codacy Static Code Analysis
apiserver/plane/settings/common.py

[notice] 270-270: apiserver/plane/settings/common.py#L270
Trailing whitespace

Additional comments not posted (18)
.env.example (1)

12-16: LGTM!

The new environment variables for RabbitMQ configuration are correctly defined and follow the standard naming convention. The default placeholder values are appropriate for an example file.

apiserver/requirements/base.txt (1)

20-20: LGTM!

The new dependency django-celery-results is consistent with the transition to RabbitMQ for task queuing and result storage.

Ensure that version 2.5.1 is compatible with the other dependencies and the project's Python version. You can run the following script to check for any potential compatibility issues:

Verification successful

Dependency Compatibility Verified

The addition of django-celery-results==2.5.1 is compatible with the existing Django 4.2.15 and Celery 5.4.0 dependencies. However, please ensure that the project's Python version is compatible, typically Python 3.8 or above, to avoid any runtime issues.

  • Django version: 4.2.15
  • Celery version: 5.4.0
  • No explicit Python version requirement found
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify compatibility of django-celery-results with other dependencies and Python version.

# Test: Check Python version. Expect: Python version 3.x.
python --version

# Test: Check Django version. Expect: Django version 4.2.15.
rg --type python -A 5 $'Django=='

# Test: Check Celery version. Expect: Celery version 5.4.0.
rg --type python -A 5 $'celery=='

# Test: Check for any known compatibility issues between django-celery-results 2.5.1 and other dependencies. Expect: No known issues.
rg --type python -A 5 $'django-celery-results=='

Length of output: 299


Script:

#!/bin/bash
# Search for Django version in requirements files
rg 'Django==' -A 0

# Search for Celery version in requirements files
rg 'celery==' -A 0

# Search for Python version requirements in requirements files or configuration files
rg 'python_requires' -A 0

# Check for any known compatibility issues with django-celery-results==2.5.1
rg 'django-celery-results==' -A 0

Length of output: 251

deploy/selfhost/variables.env (4)

32-32: LGTM!

The RABBITMQ_HOST environment variable is correctly set to the hostname of the RabbitMQ service.


33-33: LGTM!

The RABBITMQ_PORT environment variable is correctly set to the default RabbitMQ port.


36-36: LGTM!

The RABBITMQ_VHOST environment variable is appropriately set to a dedicated virtual host for the application.


37-37: Clarify the usage of AMQP_URL.

The AMQP_URL environment variable is introduced with an empty value. Please clarify the following:

  • Is the AMQP_URL intended to be set elsewhere, such as in a separate configuration file or through a runtime environment variable?
  • If the AMQP_URL is not required for the application, consider removing it from this file to avoid confusion.
apiserver/.env.example (1)

23-28: LGTM!

The new RabbitMQ configuration settings are consistent with the PR objective of integrating RabbitMQ. The settings include the necessary parameters for connecting to a RabbitMQ message broker, and the values are set to default values that match the RabbitMQ service name and credentials.

docker-compose.yml (2)

124-135: LGTM!

The code changes are approved. The new plane-mq service configuration for RabbitMQ is correctly implemented and matches the description provided in the AI-generated summary.


170-170: LGTM!

The code changes are approved. The new rabbitmq_data volume is correctly defined and referenced in the plane-mq service configuration.

docker-compose-local.yml (2)

10-22: LGTM!

The plane-mq service configuration looks good and follows best practices:

  • The image version is pinned to a specific version, which is good for reproducibility.
  • The restart policy ensures that the service will automatically restart if it stops unexpectedly.
  • The network configuration ensures that the service can communicate with other services in the dev_env network.
  • The volume configuration ensures that RabbitMQ data is persisted across container restarts.
  • Loading environment variables from the .env file is a good practice for keeping secrets out of version control.
  • Setting RabbitMQ default user, password, and vhost using environment variables is a good practice for configuring RabbitMQ.

192-192: LGTM!

The rabbitmq_data volume definition is correct and matches the volume used in the plane-mq service configuration.

deploy/selfhost/docker-compose.yml (4)

25-32: LGTM!

The new environment variables for RabbitMQ settings are correctly defined.


106-107: LGTM!

Adding plane-mq to the depends_on section of the api service is correct.


122-122: LGTM!

Adding plane-mq to the depends_on sections of the worker and beat-worker services is correct.

Also applies to: 137-137


169-174: LGTM!

The plane-mq service is correctly configured with the RabbitMQ image, restart policy, and volume settings.

apiserver/plane/settings/common.py (3)

257-262: LGTM!

The code changes are approved.


263-263: LGTM!

The code changes are approved.


266-269: LGTM!

The code changes are approved.

Comment on lines 34 to 35
RABBITMQ_USER="guest"
RABBITMQ_PASSWORD="guest"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use strong, unique credentials for RabbitMQ authentication.

Using the default "guest" username and password for RabbitMQ authentication in a production environment poses a security risk. Please consider the following:

  • Generate a strong, unique username and password for RabbitMQ authentication.
  • Store the credentials securely, such as using a secrets management system like HashiCorp Vault or AWS Secrets Manager.
  • Avoid committing sensitive information like passwords to version control.

@@ -179,8 +199,10 @@ services:
volumes:
pgdata:
redisdata:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trailing spaces.

yamllint reports a trailing spaces error at line 202.

Apply this diff to fix the issue:

-  
+
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Tools
yamllint

[error] 202-202: trailing spaces

(trailing-spaces)

@sriramveeraghanta sriramveeraghanta merged commit 2c95071 into preview Sep 2, 2024
18 of 20 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-task-queue branch September 2, 2024 12:10
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4dd5540 and 73026ff.

Files selected for processing (2)
  • deploy/selfhost/docker-compose.yml (6 hunks)
  • deploy/selfhost/variables.env (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • deploy/selfhost/variables.env
Additional context used
yamllint
deploy/selfhost/docker-compose.yml

[error] 202-202: trailing spaces

(trailing-spaces)

Additional comments not posted (5)
deploy/selfhost/docker-compose.yml (5)

25-32: LGTM!

The new environment variables for RabbitMQ are correctly defined and follow the naming convention of the file.


169-174: LGTM!

The plane-mq service is correctly defined and follows the structure of the file. The chosen RabbitMQ image version is stable and includes the management plugin.


106-107: LGTM!

Adding plane-mq to the depends_on section ensures that the api service is aware of and can depend on the RabbitMQ service during startup.


122-122: LGTM!

Adding plane-mq to the depends_on section ensures that the worker and beat-worker services are aware of and can depend on the RabbitMQ service during startup.

Also applies to: 137-137


208-208: LGTM!

The rabbitmq_data volume is correctly defined and follows the naming convention of the file.

@coderabbitai coderabbitai bot mentioned this pull request Dec 19, 2024
6 tasks
@coderabbitai coderabbitai bot mentioned this pull request Feb 28, 2025
6 tasks
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.

3 participants