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

Disable sticky sessions for backend service #8659

Merged
merged 4 commits into from
Nov 13, 2024

Conversation

azhavoro
Copy link
Contributor

@azhavoro azhavoro commented Nov 7, 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

  • New Features

    • Updated service configuration for CVAT, removing sticky cookie settings.
    • Added default storage configuration for KVrocks with 100Gi size.
    • Enhanced database authentication clarity with explicit username and database fields.
  • Bug Fixes

    • Adjusted Redis architecture to explicitly set to standalone.

Copy link
Contributor

coderabbitai bot commented Nov 7, 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 the pull request primarily involve updates to the helm-chart/values.yaml file for the CVAT application. Key modifications include the removal of Traefik ingress sticky cookie annotations, the addition of default storage settings for kvrocks, and explicit definitions for PostgreSQL authentication fields. Additionally, the Redis architecture has been set to standalone. These adjustments indicate a reconfiguration of service settings and enhancements in storage and authentication.

Changes

File Path Change Summary
helm-chart/values.yaml - Updated cvat.service.annotations from traefik.ingress.kubernetes.io/service.sticky.cookie: "true" to {}.
- Added kvrocks.defaultStorage.enabled and kvrocks.defaultStorage.size with size set to 100Gi.
- Updated postgresql.auth.username and postgresql.auth.database for clarity in authentication.
- Set redis.architecture to standalone.

Poem

🐰 In the garden where changes bloom,
The CVAT chart sheds old costume.
Annotations gone, storage now bright,
PostgreSQL's secrets brought to light.
With Redis standing proud and free,
A hop towards clarity, oh joy for me! 🌼


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

@azhavoro azhavoro force-pushed the az/disable-traefik-sticky-sessions branch from b67f182 to c7d40a8 Compare November 7, 2024 12:43
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)
helm-chart/values.yaml (1)

Line range hint 306-306: Consider Redis high availability requirements

Setting Redis architecture to standalone mode could create a single point of failure, especially critical now that sticky sessions are disabled and Redis might be handling session state. Consider:

  1. Whether Redis high availability (sentinel/cluster) is needed for your scale
  2. Impact of Redis downtime on the application
  3. Session data persistence requirements

For production deployments, consider using Redis in a high-availability configuration if:

  • Session state is stored in Redis
  • The application cannot tolerate Redis downtime
  • You need to handle failover scenarios
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 58775bf and c7d40a8.

📒 Files selected for processing (1)
  • helm-chart/values.yaml (1 hunks)
🔇 Additional comments (3)
helm-chart/values.yaml (3)

Line range hint 279-284: Verify kvrocks storage size requirements

The configured storage size of 100Gi for kvrocks seems significantly larger than other components (e.g., backend at 20Gi). Please confirm:

  1. The storage requirements justify this size
  2. Cost implications have been considered
  3. Whether a storageClassName should be explicitly specified (currently commented out)

Consider implementing storage monitoring and alerts to track usage patterns and prevent storage-related issues.


Line range hint 293-295: LGTM: PostgreSQL auth configuration is well-structured

The explicit definition of username and database fields improves configuration clarity while maintaining security through secrets.


137-137: Verify session handling after removing sticky sessions

Removing sticky sessions means requests from the same client may be routed to different backend pods. Please ensure:

  1. Session state is properly shared across pods (e.g., using Redis)
  2. No user-facing issues occur when requests hit different backends
  3. Load balancing behavior has been tested with multiple backend replicas
✅ Verification successful

Let me check the session handling implementation details to make a more informed decision.


Let me check one more aspect - the cache configuration, since the previous Redis search might have been too specific.


Based on the gathered information, I can now provide a final response:

Removing sticky sessions is safe with current session implementation

The codebase analysis shows that CVAT uses Django's built-in session management with the following safeguards:

  • A custom SessionRefreshMiddleware that efficiently manages session prolongation
  • Local memory cache as the default backend
  • Redis is only used for media caching, not for sessions

Since the session handling is stateful within each request and doesn't rely on sticky sessions for consistency, removing the sticky session configuration from the service annotations is safe.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for session handling configuration and potential issues

# Look for session configuration in Python files
echo "Checking session configuration..."
rg -l 'session|Session' --type py

# Check for Redis session store configuration
echo "Checking Redis session store usage..."
rg -l 'redis.*session|session.*redis' --type py

# Look for potential session-related issues in the codebase
echo "Checking for session-dependent code..."
rg -l 'request.session' --type py

Length of output: 1192


Script:

#!/bin/bash
# Check session configuration in settings and middleware

# Check session configuration in settings
echo "=== Session Configuration in Settings ==="
rg -A 10 "SESSION" cvat/settings/base.py

# Check session handling in middleware
echo -e "\n=== Session Handling in Middleware ==="
cat cvat/apps/iam/middleware.py

# Check if Redis is configured as session backend
echo -e "\n=== Redis Configuration ==="
rg "CACHES.*redis|SESSION.*redis" cvat/settings/base.py

Length of output: 4890


Script:

#!/bin/bash
# Check cache and session backend configuration

# Look for cache configuration
echo "=== Cache Configuration ==="
rg -A 10 "CACHES\s*=" cvat/settings/base.py

# Look for session engine configuration
echo -e "\n=== Session Engine Configuration ==="
rg "SESSION_ENGINE" cvat/settings/base.py

# Check for any Redis-related configuration
echo -e "\n=== Redis Configuration ==="
rg "redis" cvat/settings/base.py

Length of output: 1363

@azhavoro azhavoro requested a review from nmanovic as a code owner November 7, 2024 13:31
@azhavoro azhavoro requested review from SpecLad and removed request for nmanovic November 7, 2024 13:31
…ions.md

Co-authored-by: Roman Donchenko <roman@cvat.ai>
@codecov-commenter
Copy link

codecov-commenter commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.19%. Comparing base (1e7ff33) to head (63d77c1).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8659      +/-   ##
===========================================
- Coverage    74.20%   74.19%   -0.01%     
===========================================
  Files          401      401              
  Lines        43504    43504              
  Branches      3950     3950              
===========================================
- Hits         32280    32278       -2     
- Misses       11224    11226       +2     
Components Coverage Δ
cvat-ui 78.50% <ø> (-0.01%) ⬇️
cvat-server 70.51% <ø> (ø)

@azhavoro azhavoro merged commit 5520212 into develop Nov 13, 2024
34 checks passed
@cvat-bot cvat-bot bot mentioned this pull request Nov 29, 2024
@bsekachev bsekachev deleted the az/disable-traefik-sticky-sessions branch December 3, 2024 06:25
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