[PR #589] fix: synchronize remote debugging plugins across cluster nodes #601

Open
opened 2026-02-16 01:16:29 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-daemon/pull/589
Author: @fatelei
Created: 1/27/2026
Status: 🔄 Open

Base: mainHead: remote_debug


📝 Commits (1)

  • ee10c42 fix: synchronize remote debugging plugins across cluster nodes

📊 Changes

16 files changed (+460 additions, -188 deletions)

View changed files

📝 internal/cluster/node.go (+19 -0)
📝 internal/cluster/plugin.go (+32 -10)
📝 internal/cluster/plugin_test.go (+100 -127)
📝 internal/core/control_panel/daemon.go (+10 -0)
📝 internal/core/control_panel/server_debugger.go (+12 -0)
📝 internal/core/debugging_runtime/runtime_intialization_handlers.go (+1 -0)
📝 internal/core/local_runtime/setup_python_environment.go (+4 -0)
📝 internal/core/plugin_manager/cluster_tunnel.go (+22 -0)
📝 internal/core/plugin_manager/manager.go (+6 -0)
📝 internal/server/controllers/plugins.go (+3 -0)
📝 internal/server/middleware.go (+3 -1)
📝 internal/server/server.go (+3 -0)
📝 internal/service/install_plugin.go (+5 -5)
📝 internal/service/install_service/controlpanel.go (+32 -2)
📝 internal/types/models/curd/atomic.go (+84 -43)
internal/types/models/curd/atomic_test.go (+124 -0)

📄 Description

fix #588 #590 https://github.com/langgenius/dify/issues/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

  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

Changes

Core Fixes

  • 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()

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

  • Error handling improvements using errors.Is() instead of ==
  • Handle 404 for missing plugin assets gracefully
  • Handle already-installed debugging plugins gracefully

Testing

  • 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

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 #123 or Closes #123.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • Other

Essential Checklist

Testing

  • I have tested the changes locally and confirmed they work as expected
  • I have added unit tests where necessary and they pass successfully

Bug Fix (if applicable)

  • I have used GitHub syntax to close the related issue (e.g., Fixes #123 or Closes #123)

Additional Information

Please provide any additional context that would help reviewers understand the changes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langgenius/dify-plugin-daemon/pull/589 **Author:** [@fatelei](https://github.com/fatelei) **Created:** 1/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `remote_debug` --- ### 📝 Commits (1) - [`ee10c42`](https://github.com/langgenius/dify-plugin-daemon/commit/ee10c42ede0e6e09face0c126a90bf1859320e1d) fix: synchronize remote debugging plugins across cluster nodes ### 📊 Changes **16 files changed** (+460 additions, -188 deletions) <details> <summary>View changed files</summary> 📝 `internal/cluster/node.go` (+19 -0) 📝 `internal/cluster/plugin.go` (+32 -10) 📝 `internal/cluster/plugin_test.go` (+100 -127) 📝 `internal/core/control_panel/daemon.go` (+10 -0) 📝 `internal/core/control_panel/server_debugger.go` (+12 -0) 📝 `internal/core/debugging_runtime/runtime_intialization_handlers.go` (+1 -0) 📝 `internal/core/local_runtime/setup_python_environment.go` (+4 -0) 📝 `internal/core/plugin_manager/cluster_tunnel.go` (+22 -0) 📝 `internal/core/plugin_manager/manager.go` (+6 -0) 📝 `internal/server/controllers/plugins.go` (+3 -0) 📝 `internal/server/middleware.go` (+3 -1) 📝 `internal/server/server.go` (+3 -0) 📝 `internal/service/install_plugin.go` (+5 -5) 📝 `internal/service/install_service/controlpanel.go` (+32 -2) 📝 `internal/types/models/curd/atomic.go` (+84 -43) ➕ `internal/types/models/curd/atomic_test.go` (+124 -0) </details> ### 📄 Description fix #588 #590 https://github.com/langgenius/dify/issues/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 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 ## Changes ### Core Fixes - **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() ### 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 - Error handling improvements using `errors.Is()` instead of `==` - Handle 404 for missing plugin assets gracefully - Handle already-installed debugging plugins gracefully ## Testing - 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 ## 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 #123` or `Closes #123`. ## Type of Change - [x] Bug fix - [x] New feature - [x] Refactor - [ ] Performance improvement - [ ] Other ## Essential Checklist ### Testing - [x] I have tested the changes locally and confirmed they work as expected - [x] I have added unit tests where necessary and they pass successfully ### Bug Fix (if applicable) - [x] I have used GitHub syntax to close the related issue (e.g., `Fixes #123` or `Closes #123`) ## Additional Information Please provide any additional context that would help reviewers understand the changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 01:16:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-daemon#601