Skip to content

Refactor remote plugin to accept multiply connector#2666

Merged
maobaolong merged 5 commits intoLMCache:devfrom
maobaolong:supportMultiConnector
Apr 7, 2026
Merged

Refactor remote plugin to accept multiply connector#2666
maobaolong merged 5 commits intoLMCache:devfrom
maobaolong:supportMultiConnector

Conversation

@maobaolong
Copy link
Copy Markdown
Collaborator

@maobaolong maobaolong commented Mar 2, 2026

What this PR does / why we need it:

Special notes for your reviewers:

If applicable:

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

Note

Medium Risk
Touches remote connector selection and RemoteBackend initialization/reconnect paths; misconfiguration or adapter matching bugs could break remote storage connectivity, though legacy remote_url remains supported.

Overview
Adds first-class support for configuring multiple remote backends via remote_storage_plugins, including instance-qualified names like fs.primary/fs.backup, and routes each entry to its own RemoteBackend (using plugin://... URLs internally).

Extends the connector/plugin system to understand plugin naming (extract_plugin_type, ConnectorContext.plugin_name), updates built-in adapters (fs, mooncakestore) and RemoteBackend to work in plugin mode while keeping legacy remote_url working with a deprecation warning, and allows dynamic plugins to specify either a ConnectorAdapter or a RemoteConnector via a new DynamicConnectorAdapter. Docs and FS connector tests are updated to cover the new configuration patterns and multi-instance behavior.

Reviewed by Cursor Bugbot for commit 4e653f6. Bugbot is set up for automated code reviews on this repo. Configure here.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 remote storage capabilities of LMCache by refactoring its plugin system to support multiple, independently configurable remote storage connectors. This change moves away from a single remote_url to a more flexible remote_storage_plugins array, allowing for complex storage setups, such as primary and backup file systems or a mix of different storage technologies. The update ensures greater scalability and adaptability for LMCache's remote storage integrations.

Highlights

  • Multiple Remote Connectors: The remote storage plugin system has been refactored to support multiple remote storage connectors simultaneously, including multiple instances of the same connector type.
  • Configuration Update: The remote_url configuration is now deprecated. Users should transition to the new remote_storage_plugins configuration, which allows specifying multiple plugin instances and their configurations via extra_config.
  • Plugin Naming Convention: A new naming convention for plugins ({type} or {type}.{instance}) has been introduced, enabling the framework to distinguish between different instances of the same connector type.
  • Adapter Enhancements: Connector adapters now include a can_parse method to determine if they can handle a given URL or plugin name, improving flexibility in connector resolution. The ConnectorContext now passes the plugin_name to the connector for instance-specific configuration.
  • Backward Compatibility: The system maintains backward compatibility by still supporting the legacy remote_url configuration, though a deprecation warning is now logged upon its use.
  • Documentation and Tests: Documentation has been updated to reflect the new configuration methods and deprecations, and new unit tests have been added to validate the functionality of multiple FS connector instances.

🧠 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/developer_guide/extending_lmcache/remote_storage_plugins.rst
    • Added a deprecation note for the remote_url configuration.
    • Introduced a new section detailing the plugin naming convention ({type} or {type}.{instance}).
    • Provided examples for configuring built-in connectors via remote_storage_plugins for single, multiple, and mixed types.
    • Updated the guide for integrating custom remote storage to reflect the new configuration approach, including examples for multiple custom connector instances.
    • Modified the ConnectorAdapter example to include the new can_parse method and pass plugin_name to the connector context.
  • lmcache/v1/storage_backend/init.py
    • Added noqa: F401 to the RemoteBackend import.
    • Modified CreateStorageBackends to iterate through config.remote_storage_plugins to instantiate multiple RemoteBackend instances.
    • Introduced a deprecation warning when the legacy remote_url configuration is used.
  • lmcache/v1/storage_backend/connector/init.py
    • Added a new helper function extract_plugin_type to parse plugin names.
    • Updated ConnectorContext to include plugin_name in its constructor and attributes.
    • Modified ConnectorManager to pass plugin_name to the ConnectorContext during initialization.
    • Adjusted _remote_adapters_plugin_launcher to handle extra_config more robustly and to skip warnings for built-in adapters.
    • Updated the CreateConnector function to accept and pass plugin_name.
  • lmcache/v1/storage_backend/connector/fs_adapter.py
    • Added a PLUGIN_TYPE constant for the 'fs' connector.
    • Implemented the can_parse method to recognize both fs:// URLs and plugin://fs[.instance] names.
    • Modified create_connector to pass plugin_name and conditionally extract base_paths_str from the URL for legacy configurations.
  • lmcache/v1/storage_backend/connector/fs_connector.py
    • Refactored the __init__ method to accept plugin_name and make base_paths_str optional.
    • Updated the logic to dynamically resolve the base_path from extra_config using the plugin_name if base_paths_str is not explicitly provided.
  • lmcache/v1/storage_backend/connector/mooncakestore_adapter.py
    • Added a PLUGIN_TYPE constant for the 'mooncakestore' connector.
    • Implemented the can_parse method to recognize relevant plugin names.
    • Modified create_connector to remove direct URL parsing and pass plugin_name to the MooncakestoreConnector.
  • lmcache/v1/storage_backend/connector/mooncakestore_connector.py
    • Refactored the __init__ method to remove direct host, port, and dev_name parameters, instead relying on configuration resolved via plugin_name.
    • Removed the logic that directly set master_server_address and device_name from constructor arguments.
  • lmcache/v1/storage_backend/remote_backend.py
    • Modified the __init__ method to accept an optional plugin_name.
    • Updated the remote_url initialization logic to construct a plugin:// URL when plugin_name is provided, otherwise falling back to config.remote_url.
    • Adjusted init_connection to create a virtual plugin:// URL for CreateConnector when a plugin_name is active.
  • tests/v1/storage_backend/test_fs_connector.py
    • Added create_test_config_with_plugin to generate configurations for single plugin instances.
    • Added create_test_config_with_dual_plugins to generate configurations for multiple plugin instances.
    • Added test_init_with_plugin to verify FSConnector initialization using the new plugin configuration.
    • Added test_dual_fs_instances to confirm that two distinct FS connector instances can operate independently with separate paths.
Activity
  • The pull request includes new unit tests to cover the refactored remote plugin functionality, specifically for multiple filesystem connector instances.
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.

@maobaolong maobaolong force-pushed the supportMultiConnector branch from 1bf5708 to a4c0731 Compare March 2, 2026 06:00
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 refactors the remote storage plugin system to support multiple connectors, deprecating the old remote_url in favor of a remote_storage_plugins list. The new system allows multiple instances of the same connector type and mixing different types. However, the implementation introduces critical security vulnerabilities related to arbitrary code execution and path traversal, stemming from dynamic loading of plugin modules from potentially untrusted configuration sources and the use of unvalidated filesystem paths for storage connectors. Additionally, there is a critical issue with the mooncakestore connector not correctly supporting multiple instances, and inconsistencies in the updated documentation need to be addressed to avoid user confusion.

Comment thread lmcache/v1/storage_backend/connector/mooncakestore_connector.py
Comment thread lmcache/v1/storage_backend/connector/fs_connector.py
Comment thread docs/source/developer_guide/extending_lmcache/remote_storage_plugins.rst Outdated
Comment thread docs/source/developer_guide/extending_lmcache/remote_storage_plugins.rst Outdated
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

@deng451e deng451e left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread lmcache/v1/storage_backend/__init__.py
Comment thread lmcache/v1/storage_backend/remote_backend.py
Comment thread lmcache/v1/storage_backend/connector/mooncakestore_connector.py
@maobaolong maobaolong force-pushed the supportMultiConnector branch from cece3c0 to 3c158d9 Compare April 6, 2026 11:52
@maobaolong maobaolong enabled auto-merge (squash) April 6, 2026 11:54
@github-actions github-actions Bot added the full Run comprehensive tests on this PR label Apr 6, 2026
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
@maobaolong maobaolong force-pushed the supportMultiConnector branch from 3c158d9 to 560e317 Compare April 7, 2026 05:22
@chunxiaozheng
Copy link
Copy Markdown
Collaborator

@maobaolong Good job! A minor question, is these AI review comments make sense? if it not make sense, we can mark it as resolved.

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!

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
@maobaolong maobaolong force-pushed the supportMultiConnector branch from 02b9678 to 4e653f6 Compare April 7, 2026 07:32
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4e653f6. Configure here.

loop=context.loop,
local_cpu_backend=context.local_cpu_backend,
config=context.config,
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

DynamicConnectorAdapter omits plugin_name from connector creation

Medium Severity

DynamicConnectorAdapter.create_connector doesn't pass context.plugin_name to the dynamically loaded RemoteConnector class. This prevents custom RemoteConnector subclasses from resolving per-instance configuration (e.g., from extra_config), breaking multi-instance support for dynamic plugins, unlike builtin adapters.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4e653f6. Configure here.

@maobaolong maobaolong merged commit aed852f into LMCache:dev Apr 7, 2026
35 checks passed
Oasis-Git pushed a commit to Oasis-Git/LMCache that referenced this pull request Apr 13, 2026
* Refactor remote plugin to accept multiply connector.

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

* Skip module_path/class_name check for built-in adapters

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

* Add document related

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

* Fix to use DynamicConnectorAdapter to load external connector plugin

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

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.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.

4 participants