Skip to content

hanyu.liang's avatar <fix>[plugin]: add newDriverInstance for isolated drivers#3540

Open
ZStack-Robot wants to merge 1 commit into5.5.0from
sync/hanyu.liang/fix-82729@@2
Open

hanyu.liang's avatar <fix>[plugin]: add newDriverInstance for isolated drivers#3540
ZStack-Robot wants to merge 1 commit into5.5.0from
sync/hanyu.liang/fix-82729@@2

Conversation

@ZStack-Robot
Copy link
Collaborator

Root Cause

CryptoClientDriver singleton shared by all pools causes concurrent state corruption. When heartbeat detection calls connect() on the singleton with pool 3's config, it overwrites the server URL from 10.20.109.2 to 10.20.109.3, causing data protection flow's HMAC request to be sent to the wrong server with a token from a different server.

Changes

  • Add newDriverInstance(String) to PluginManager interface
  • Implement in PluginManagerImpl via reflection from singleton's class

Resolves: ZSTAC-82729

sync from gitlab !9400

Add newDriverInstance() method to PluginManager interface and implementation.
Unlike getPlugin() which returns a shared singleton, this method creates
a fresh instance each time via reflection to avoid concurrent state
corruption when multiple callers need isolated driver configurations.

Resolves: ZSTAC-82729

Change-Id: Ife8c01012dc38780d91f2b67c04c7a1ac8f9bd1f
@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: 17b0edc3-bf73-4747-99c2-2bd054b7ce0a

📥 Commits

Reviewing files that changed from the base of the PR and between 5c0eddd and 4325420.

📒 Files selected for processing (2)
  • core/src/main/java/org/zstack/core/plugin/PluginManager.java
  • core/src/main/java/org/zstack/core/plugin/PluginManagerImpl.java

Walkthrough

PluginManager 接口和其实现类添加了新的泛型方法 newDriverInstance(String pluginUuid),用于通过反射创建独立的 PluginDriver 实例,而非使用现有单例模式,为调用方提供隔离的驱动实例创建能力。

Changes

Cohort / File(s) Summary
Plugin Driver 实例工厂方法
core/src/main/java/org/zstack/core/plugin/PluginManager.java
添加泛型方法声明 <T extends PluginDriver> T newDriverInstance(String pluginUuid);,定义创建独立驱动实例的新公共 API。
Plugin Driver 实例工厂实现
core/src/main/java/org/zstack/core/plugin/PluginManagerImpl.java
实现 newDriverInstance(String pluginProductKey) 方法,通过单例查找和反射无参构造方式创建新实例;缺失插件或实例化失败均抛出 CloudRuntimeException

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 工厂新生功能来,
反射创建驱动快,
隔离实例无忧虑,
插件管理更灵活,
蹦蹦跳跳乐开怀!


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Title check ❌ Error 标题包含了规定的格式前缀 [plugin],但长度为 78 字符,超过了 72 字符的限制。 缩短标题至 72 字符以内,例如改为 '[plugin]: add newDriverInstance for isolated drivers' 或更简洁的表述。
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed 拉取请求描述清晰地阐述了根本原因、所做的具体改动以及解决的问题编号,与代码变更高度相关。
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/hanyu.liang/fix-82729@@2
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

2 participants