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

Nuclio functions in cvat network #8777

Merged
merged 6 commits into from
Dec 10, 2024
Merged

Nuclio functions in cvat network #8777

merged 6 commits into from
Dec 10, 2024

Conversation

bsekachev
Copy link
Member

@bsekachev bsekachev commented Dec 5, 2024

Motivation and context

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved error handling to provide clearer and more informative error messages when HTTP errors occur.
  • Configuration Updates

    • Enhanced environment variable management for the cvat_server and cvat_grafana services, including new settings for better service initialization.
    • Updated deployment scripts to reflect new naming conventions for Redis-related environment variables and added platform configuration options for more control during deployment.

Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes in this pull request involve modifications across several files, primarily focusing on error handling in a decorator function, updates to environment variables in Docker configuration, and adjustments in deployment scripts for serverless functions. The return_response decorator now provides more informative error messages. The docker-compose.yml file has been enhanced with new environment variables and service dependencies. Additionally, deployment scripts have been updated to rename certain environment variables and introduce a new platform configuration option.

Changes

File Path Change Summary
cvat/apps/lambda_manager/views.py Updated error handling in return_response decorator to provide more informative error messages from HTTPError.
docker-compose.yml Added name: cvat. Updated environment variables for cvat_server and cvat_grafana, including new settings and entrypoint modifications.
serverless/deploy_cpu.sh Renamed environment variables from CVAT_REDIS_* to FUNCTIONS_REDIS_*. Added --platform-config option for deployment.
serverless/deploy_gpu.sh Renamed environment variables from CVAT_REDIS_* to FUNCTIONS_REDIS_*. Added --platform-config option for deployment.

Poem

In the world of code, we hop and play,
With error messages clearer, come what may!
Docker's new settings, a joyful cheer,
For functions deploying, we hold so dear.
With each little change, our code's a delight,
A rabbit's work is never done, but oh, what a sight! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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.

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

🧹 Outside diff range and nitpick comments (1)
cvat/apps/lambda_manager/views.py (1)

986-987: Improved error message handling for HTTP errors

The changes enhance error reporting by extracting the detailed error message from the response text when available. This provides more informative feedback to clients about what went wrong during HTTP requests.

Consider adding error message sanitization to prevent potential security issues with raw error messages:

-                msg = err.response.text if hasattr(err, 'response') else str(err)
+                msg = str(err)
+                if hasattr(err, 'response'):
+                    try:
+                        # Attempt to parse and sanitize the error message
+                        msg = err.response.text[:1000]  # Limit message length
+                    except Exception:
+                        msg = str(err)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d86c816 and 86c0dc0.

📒 Files selected for processing (4)
  • cvat/apps/lambda_manager/views.py (1 hunks)
  • docker-compose.yml (1 hunks)
  • serverless/deploy_cpu.sh (1 hunks)
  • serverless/deploy_gpu.sh (1 hunks)
🔇 Additional comments (5)
serverless/deploy_gpu.sh (2)

21-23: Environment variable renaming improves clarity

The renaming from CVAT_REDIS_* to FUNCTIONS_REDIS_* better reflects the scope and purpose of these variables in the context of serverless functions.


24-24: Verify network configuration compatibility

The new platform config sets the network to "cvat_cvat". Let's verify this network exists and is properly configured.

serverless/deploy_cpu.sh (1)

29-32: Changes maintain consistency with GPU deployment

The modifications mirror those in deploy_gpu.sh, maintaining consistency across deployment scripts. This is good practice for maintainability.

docker-compose.yml (2)

6-7: Project naming enhances isolation

Adding explicit project name "cvat" is good practice as it:

  1. Prevents naming conflicts with other compose projects
  2. Creates predictable network names (cvat_cvat) for Nuclio functions

Line range hint 1-464: Verify Redis service accessibility for Nuclio functions

The Redis services need to be accessible to the Nuclio functions through the "cvat_cvat" network.

Consider documenting the network architecture and service dependencies in the project documentation to help with future maintenance and troubleshooting.

✅ Verification successful

Redis services are properly configured and accessible on the "cvat" network

Both Redis services (cvat_redis_inmem and cvat_redis_ondisk) are correctly configured:

  • They are connected to the "cvat" network
  • They expose standard Redis ports (6379 for inmem, 6666 for ondisk)
  • They are accessible via their container names as hostnames
  • The environment variables CVAT_REDIS_INMEM_HOST and CVAT_REDIS_ONDISK_HOST are properly set
  • The services are included in the no_proxy list to ensure direct communication
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Redis services configuration
# Expected: Find Redis services on the cvat network with correct ports

# Check Redis service definitions
echo "Checking Redis service configurations..."
rg -A 10 'cvat_redis_(inmem|ondisk):\s*$' docker-compose.yml

# Verify network configuration for Redis services
echo "Checking Redis services network configuration..."
rg -A 5 'networks:\s*- cvat' docker-compose.yml

Length of output: 1377


Script:

#!/bin/bash
# Let's verify the network configuration more specifically for Redis services and Nuclio

# Check Redis services network configuration
echo "=== Redis Services Network Configuration ==="
rg -B 2 -A 2 'networks:.*\s+- cvat' docker-compose.yml

# Check if Redis services are properly defined with network configuration
echo -e "\n=== Redis Services Complete Definition ==="
rg --multiline --multiline-dotall 'cvat_redis_(inmem|ondisk):\s*\{[^}]+\}' docker-compose.yml

# Check if there's any Nuclio-related network configuration
echo -e "\n=== Nuclio Network Configuration ==="
rg -i 'nuclio.*network|network.*nuclio' docker-compose.yml

# Check environment variables related to Redis hosts
echo -e "\n=== Redis Host Environment Variables ==="
rg 'CVAT_REDIS_(INMEM|ONDISK)_HOST' docker-compose.yml

Length of output: 742


Script:

#!/bin/bash
# Let's verify the complete network configuration for Redis services and check the network aliases

# Check complete Redis service definitions including networks
echo "=== Complete Redis Service Definitions ==="
rg -A 15 'cvat_redis_(inmem|ondisk):' docker-compose.yml

# Check all network definitions in the compose file
echo -e "\n=== Network Definitions ==="
rg -A 5 '^networks:' docker-compose.yml

# Check no_proxy settings that might affect Redis connectivity
echo -e "\n=== No Proxy Configuration ==="
rg 'no_proxy:' docker-compose.yml

Length of output: 1767

@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.93%. Comparing base (094c62d) to head (b31f96c).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8777   +/-   ##
========================================
  Coverage    73.92%   73.93%           
========================================
  Files          409      409           
  Lines        43957    43957           
  Branches      3986     3986           
========================================
+ Hits         32497    32501    +4     
+ Misses       11460    11456    -4     
Components Coverage Δ
cvat-ui 78.37% <ø> (+0.01%) ⬆️
cvat-server 70.13% <ø> (ø)

serverless/deploy_cpu.sh Outdated Show resolved Hide resolved
@SpecLad SpecLad merged commit 9a08a0c into develop Dec 10, 2024
35 checks passed
@SpecLad SpecLad deleted the bs/updated_nuclio branch December 10, 2024 15:31
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