Skip to content

Add a backend api to support dynamic close&create backends#2622

Merged
maobaolong merged 5 commits intoLMCache:devfrom
maobaolong:dynamicUpdateBackend
Feb 24, 2026
Merged

Add a backend api to support dynamic close&create backends#2622
maobaolong merged 5 commits intoLMCache:devfrom
maobaolong:dynamicUpdateBackend

Conversation

@maobaolong
Copy link
Copy Markdown
Collaborator

@maobaolong maobaolong commented Feb 19, 2026

What this PR does / why we need it:

allow for dynamic management of storage backends. This new functionality provides operators with the flexibility to modify and reconfigure storage solutions, such as switching backend types or updating connectors, without the need to restart the entire serving engine. The changes aim to improve operational agility and reduce downtime during configuration adjustments.

Special notes for your reviewers:

If applicable:

  • this PR contains user facing changes - docs added
  • this PR contains unit tests

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @maobaolong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the LMCache system by introducing a set of internal API endpoints that allow for dynamic management of storage backends. This new functionality provides operators with the flexibility to modify and reconfigure storage solutions, such as switching backend types or updating connectors, without the need to restart the entire serving engine. The changes aim to improve operational agility and reduce downtime during configuration adjustments.

Highlights

  • Dynamic Backend Management API: Introduced new internal API endpoints to dynamically list, close, and create storage backends at runtime without requiring a service restart. This enables flexible configuration changes on the fly.
  • Runtime Backend Switching: Enabled the ability to switch between different storage configurations, such as migrating from a LocalDiskBackend to a GdsBackend or changing a RemoteBackend connector from filesystem to Redis, through API calls.
  • StorageManager Enhancements: Added list_backends, close_backend, and create_backends methods to the StorageManager to support the new dynamic management capabilities, including handling existing backends and refreshing internal references.
  • Comprehensive API Documentation and Testing: Provided detailed documentation for the new dynamic backend management API endpoints, including use-case examples, and added a dedicated test suite to ensure their correct functionality and robustness.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docs/source/internal_api_server/dynamic_backend_management.rst
    • Added new documentation for the dynamic backend management API, detailing endpoints for listing, closing, and creating backends.
    • Included use-case examples for switching backend types and updating remote connectors.
  • lmcache/v1/internal_api_server/vllm/backend_api.py
    • Implemented new FastAPI routes for /backends to handle GET, DELETE, and POST requests.
    • Added logic to interact with the StorageManager for listing, closing, and creating storage backends.
    • Included error handling and appropriate HTTP status responses for API operations.
  • lmcache/v1/storage_backend/storage_manager.py
    • Introduced list_backends method to return a dictionary of active backend names and their class types.
    • Added close_backend method to safely shut down and remove a specified storage backend.
    • Implemented create_backends method to instantiate new backends based on the current configuration, skipping already existing ones and refreshing internal references.
  • tests/v1/internal_api_server/test_backend_api.py
    • Created a new test file with fixtures for mocking StorageManager and LMCacheEngine.
    • Added test cases for GET /backends to verify listing functionality and error handling.
    • Included test cases for DELETE /backends/{backend_name} to confirm backend closing and removal.
    • Developed test cases for POST /backends to validate new backend creation.
    • Implemented an end-to-end test simulating the full backend switch workflow (close, update config, create, verify).
Activity
  • No specific activity (comments, reviews, progress updates) was provided in the pull request context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature for dynamically managing storage backends at runtime via new internal API endpoints. However, it introduces a critical Remote Code Execution (RCE) vulnerability due to dynamic module loading based on runtime-modifiable configuration, and a medium-severity information leakage vulnerability by exposing detailed exception messages. Additionally, the review focuses on improving API consistency, standardizing on JSONResponse, enhancing error logging for better diagnostics, and utilizing modern Python syntax.

Comment thread lmcache/v1/storage_backend/storage_manager.py
Comment thread lmcache/v1/internal_api_server/vllm/backend_api.py
Comment thread lmcache/v1/internal_api_server/vllm/backend_api.py
Comment thread lmcache/v1/internal_api_server/vllm/backend_api.py
Comment thread lmcache/v1/internal_api_server/vllm/backend_api.py Outdated
Comment thread tests/v1/internal_api_server/test_backend_api.py
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
@maobaolong maobaolong added the full Run comprehensive tests on this PR label Feb 21, 2026
@sammshen
Copy link
Copy Markdown
Contributor

NOTE: missing recreate function

should the storage manager init also call the same create_backends()? we should have a CreateStorageBackends and a create_backends()

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
@maobaolong
Copy link
Copy Markdown
Collaborator Author

@sammshen recreate api added. PTAL

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Copy link
Copy Markdown
Contributor

@sammshen sammshen left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Collaborator

@chunxiaozheng chunxiaozheng left a comment

Choose a reason for hiding this comment

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

lgtm

@maobaolong maobaolong merged commit cb7bc24 into LMCache:dev Feb 24, 2026
24 checks passed
sammshen pushed a commit to sammshen/LMCache that referenced this pull request Mar 1, 2026
)

* Add a backend api to support dynamic  close&create backends

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* CreateBackend with skip existing backend parameter

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* fix gemini comments

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* address comments

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Use create_backends while StorageManager init

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
hlin99 pushed a commit to hlin99/LMCache that referenced this pull request Mar 2, 2026
)

* Add a backend api to support dynamic  close&create backends

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* CreateBackend with skip existing backend parameter

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* fix gemini comments

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* address comments

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Use create_backends while StorageManager init

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
mauryaavinash95 pushed a commit to mauryaavinash95/LMCache that referenced this pull request Mar 7, 2026
)

* Add a backend api to support dynamic  close&create backends

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* CreateBackend with skip existing backend parameter

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* fix gemini comments

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* address comments

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Use create_backends while StorageManager init

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
shaoxiawjc pushed a commit to shaoxiawjc/LMCache that referenced this pull request Mar 11, 2026
)

* Add a backend api to support dynamic  close&create backends

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* CreateBackend with skip existing backend parameter

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* fix gemini comments

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* address comments

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Use create_backends while StorageManager init

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: shaoxiawjc <wjc2800@163.com>
realAaronWu pushed a commit to realAaronWu/LMCache that referenced this pull request Mar 20, 2026
)

* Add a backend api to support dynamic  close&create backends

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* CreateBackend with skip existing backend parameter

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* fix gemini comments

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* address comments

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Use create_backends while StorageManager init

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: Aaron Wu <aaron.wu@dell.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full Run comprehensive tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants