-
Notifications
You must be signed in to change notification settings - Fork 275
fix: synchronize remote debugging plugins across cluster nodes #589
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @fatelei, 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 addresses critical issues related to the synchronization and management of remote debugging plugins within a cluster environment. Previously, these plugins were not reliably registered or discoverable across different nodes, leading to invocation failures. The changes ensure that remote debugging plugins are correctly registered, their IDs are consistently managed, and their lifecycle events (connection/disconnection) are propagated across the cluster, significantly improving the stability and functionality of distributed debugging. Highlights
🧠 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. Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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 effectively addresses issues with remote debugging plugin synchronization across cluster nodes by making registration idempotent, unifying plugin ID formats, and ensuring plugins are correctly registered with the cluster. However, a high-severity cache key injection vulnerability was identified in the cache key generation logic, which could allow an attacker to poison the cache and potentially access or manipulate plugin installations belonging to other tenants. It is recommended to sanitize inputs used in cache keys or use a more secure serialization format. Additionally, my review includes suggestions to improve error handling, prevent potential race conditions, enhance test stability by avoiding fixed sleeps, and refactor duplicated code for better maintainability. A bug where a 'not found' error incorrectly results in a 200 OK response was also found and a fix provided.
Remote debugging plugins were not being synchronized across cluster nodes,
causing "no plugin available nodes found" errors when trying to invoke
plugins from different nodes.
1. **Remote debugging plugins not registered to cluster** - The
`ClusterTunnel` notifier was not being added to ControlPanel
2. **Plugin ID inconsistency** - Remote plugins used different plugin_id
formats during installation vs. querying
3. **Non-idempotent registration** - `RegisterPlugin` failed on reconnection
with "plugin has been registered" error
- **internal/types/models/curd/atomic.go**:
- Unify plugin_id calculation for remote plugins (author/name without version)
- Remove plugin_id from plugin query conditions
- Clear old cache when plugin_id is updated
- **internal/cluster/plugin.go**:
- Make `RegisterPlugin` idempotent by updating existing plugin instead
of returning error
- **internal/core/control_panel/daemon.go**:
- Add cluster field to ControlPanel
- Add SetCluster() method for lazy cluster initialization
- **internal/core/control_panel/server_debugger.go**:
- Register remote debugging plugins to cluster on connection
- Unregister from cluster on disconnection
- **internal/core/plugin_manager/manager.go**:
- Add SetCluster() method to set cluster after initialization
- **internal/server/server.go**:
- Call SetCluster() instead of AddClusterTunnel()
Only remote debugging plugins are synchronized across cluster nodes.
Local plugins run only on the node where they are installed and are
not registered to the cluster.
- Error handling improvements using `errors.Is()` instead of `==`
- Handle 404 for missing plugin assets gracefully
- Handle already-installed debugging plugins gracefully
- Remote debugging plugin can be invoked from any node in the cluster
- Plugin reconnection works without errors
- Cache invalidation works correctly when plugin_id changes
fix #588 #590 langgenius/dify#31684
Problem
Remote debugging plugins were not being synchronized across cluster nodes, causing "no plugin available nodes found" errors when trying to invoke plugins from different nodes.
Root Causes
ClusterTunnelnotifier was not being added to ControlPanelRegisterPluginfailed on reconnection with "plugin has been registered" errorChanges
Core Fixes
internal/types/models/curd/atomic.go:
internal/cluster/plugin.go:
RegisterPluginidempotent by updating existing plugin instead of returning errorinternal/core/control_panel/daemon.go:
internal/core/control_panel/server_debugger.go:
internal/core/plugin_manager/manager.go:
internal/server/server.go:
Design Decision
Only remote debugging plugins are synchronized across cluster nodes. Local plugins run only on the node where they are installed and are not registered to the cluster.
Additional Improvements
errors.Is()instead of==Testing
Description
Please provide a brief description of the changes made in this pull request.
Please also include the issue number if this is related to an issue using the format
Fixes #123orCloses #123.Type of Change
Essential Checklist
Testing
Bug Fix (if applicable)
Fixes #123orCloses #123)Additional Information
Please provide any additional context that would help reviewers understand the changes.