-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[plugin-premium]: GPU/VM page keeps loading when shutting down or encountering errors in Zaku cluster. #3126
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: 5.5.0
Are you sure you want to change the base?
Conversation
Walkthrough新增两个公共扩展点接口到包 Changes
Sequence Diagram(s)(无序列图;变更仅新增接口契约,未引入新的多组件控制流或具体实现。) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 分钟 Poem
Pre-merge checks and finishing touchesImportant Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml) Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (2)**/*.*⚙️ CodeRabbit configuration file
Files:
**/*.java⚙️ CodeRabbit configuration file
Files:
🧠 Learnings (2)📓 Common learnings📚 Learning: 2025-08-12T03:35:21.034ZApplied to files:
🧬 Code graph analysis (1)header/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java (1)
Comment |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
header/src/main/java/org/zstack/header/zql/BeforeApiCallExtensionPoint.javaheader/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java
🧰 Additional context used
📓 Path-based instructions (2)
**/*.*
⚙️ CodeRabbit configuration file
**/*.*: - 代码里不应当有有中文,包括报错、注释等都应当使用正确的、无拼写错误的英文来写
Files:
header/src/main/java/org/zstack/header/zql/BeforeApiCallExtensionPoint.javaheader/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java
**/*.java
⚙️ CodeRabbit configuration file
**/*.java: ## 1. API 设计要求
- API 命名:
- API 名称必须唯一,不能重复。
- API 消息类需要继承
APIMessage;其返回类必须继承APIReply或APIEvent,并在注释中用@RestResponse进行标注。- API 消息上必须添加注解
@RestRequest,并满足如下规范:
path:
- 针对资源使用复数形式。
- 当 path 中引用消息类变量时,使用
{variableName}格式。- HTTP 方法对应:
- 查询操作 →
HttpMethod.GET- 更新操作 →
HttpMethod.PUT- 创建操作 →
HttpMethod.POST- 删除操作 →
HttpMethod.DELETE- API 类需要实现
__example__方法以便生成 API 文档,并确保生成对应的 Groovy API Template 与 API Markdown 文件。
2. 命名与格式规范
类名:
- 使用 UpperCamelCase 风格。
- 特殊情况:
- VO/AO/EO 类型类除外。
- 抽象类采用
Abstract或Base前缀/后缀。- 异常类应以
Exception结尾。- 测试类需要以
Test或Case结尾。方法名、参数名、成员变量和局部变量:
- 使用 lowerCamelCase 风格。
常量命名:
- 全部大写,使用下划线分隔单词。
- 要求表达清楚,避免使用含糊或不准确的名称。
包名:
- 统一使用小写,使用点分隔符,每个部分应是一个具有自然语义的英文单词(参考 Spring 框架的结构)。
命名细节:
- 避免在父子类或同一代码块中出现相同名字的成员或局部变量,防止混淆。
- 命名缩写:
- 不允许使用不必要的缩写,如:
AbsSchedulerJob、condi、Fu等。应使用完整单词提升可读性。
3. 编写自解释代码
意图表达:
- 避免使用布尔型参数造成含义不明确。例如:
- 对于
stopAgent(boolean ignoreError),建议拆分为不同函数(如stopAgentIgnoreError()),或使用枚举表达操作类型。- 命名应尽量用完整的单词组合表达意图,并在名称中体现数据类型或用途(例如在常量与变量名称中,将类型词放在末尾)。
- 避免使用魔法值(Magic Value):
直接使用未经定义的数值或字符串(如 if (status == 5))应替换为枚举或常量。
示例:
// 错误示例:魔法值
if (user.getStatus() == 5) { ... }
// 正确示例:常量或枚举
public static final int STATUS_ACTIVE = 5;
if (user.getStatus() == STATUS_ACTIVE) { ... }
// 或使用枚举
enum UserStatus { ACTIVE, INACTIVE }
注释:
- 代码应尽量做到自解释,对少于两行的说明可以直接写在代码中。
- 对于较长的注释,需要仔细校对并随代码更新,确保内容正确。
- 接口方法不应有多余的修饰符(例如
public),且必须配有有效的 Javadoc 注释。
4. 流程控制和结构优化
if...else 的使用:
- 应尽量减少 if...else 结构的使用,建议:
- 限制嵌套层级最多为两层,且内层不应再出现
else分支。- 尽早返回(Early Return),将条件判断中的处理逻辑提前结束或抽成独立方法。
- 使用 Java Stream 或 Lambda 表达式代替冗长的循环与条件判断。
条件判断:
- if 条件表达不宜过长或过于复杂,必要时可以将条件抽成 boolean 变量描述。
代码块长度:
...
Files:
header/src/main/java/org/zstack/header/zql/BeforeApiCallExtensionPoint.javaheader/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java
🧠 Learnings (2)
📓 Common learnings
Learnt from: zstack-robot-1
Repo: MatheMatrix/zstack PR: 2360
File: network/src/main/java/org/zstack/network/l3/L3BasicNetwork.java:449-490
Timestamp: 2025-08-04T04:48:19.103Z
Learning: ZStack项目在cherry-pick操作中,即使发现了性能优化机会(如IP地址批量保存的内存优化),也严格遵循不做额外修改的政策,优先保证cherry-pick的完整性和一致性。
📚 Learning: 2025-08-12T03:35:21.034Z
Learnt from: zstack-robot-1
Repo: MatheMatrix/zstack PR: 2419
File: network/src/main/java/org/zstack/network/l3/L3BasicNetwork.java:287-297
Timestamp: 2025-08-12T03:35:21.034Z
Learning: In the ZStack codebase, extension points may be designed for different execution phases/orders in the same operation. For example, IpRangeDeletionExtensionPoint executes during IP range deletion process, while AfterDeleteIpRangeExtensionPoint executes after the entire deletion process is complete. This allows different plugins to hook into appropriate lifecycle stages.
Applied to files:
header/src/main/java/org/zstack/header/zql/BeforeApiCallExtensionPoint.javaheader/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java
🧬 Code graph analysis (1)
header/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java (1)
header/src/main/java/org/zstack/header/storage/primary/PrimaryStorageHistoricalUsageBaseVO.java (1)
org(11-45)
🔇 Additional comments (1)
header/src/main/java/org/zstack/header/zql/BeforeApiCallExtensionPoint.java (1)
3-25: 该扩展点接口定义规范,但实现与使用未找到。对扩展点接口定义的审查表明:
- Javadoc 注释完整且使用了正确的英文
- 命名遵循 UpperCamelCase 规范
- 方法签名清晰
但搜索结果表明存在以下问题:
- 未找到实现类 - 扩展点接口已定义但在可搜索范围内无具体实现
- 未找到调用位置 - 代码库中无处调用
beforeApiCall方法- 未找到 Zaku 相关代码 - 与 PR 目标"GPU/VM 页面在 Zaku 集群关机或错误时的持续加载问题"的关联无法确认
需要确认该扩展点是否已在其他模块实现,以及实现是否能有效解决页面持续加载的根本原因。
| /** | ||
| * BeforeCallZWatchReturnWithExtensionPoint is an extension point that allows plugins | ||
| * to perform custom operations before executing ZQL return with queries. | ||
| * | ||
| * This provides a hook for business modules to execute pre-processing logic | ||
| * (such as health checks, validation, etc.) before monitoring data is retrieved. | ||
| */ | ||
| public interface BeforeCallZWatchReturnWithExtensionPoint { | ||
| /** | ||
| * Check if this extension supports the given VO class | ||
| * @param voClass the VO class to check | ||
| * @return true if this extension supports the VO class, false otherwise | ||
| */ | ||
| boolean supports(Class<?> voClass); | ||
|
|
||
| /** | ||
| * Perform operations before executing ZQL return with query. | ||
| * This allows business modules to trigger health checks or other pre-processing logic. | ||
| * | ||
| * @param voClass the VO class type | ||
| * @param uuids the list of resource UUIDs to process | ||
| */ | ||
| void beforeCallZWatch(Class<?> voClass, List<String> uuids); | ||
| } |
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.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for implementations of BeforeCallZWatchReturnWithExtensionPoint
echo "=== 查找 BeforeCallZWatchReturnWithExtensionPoint 的实现类 ==="
rg -nP --type=java 'implements.*BeforeCallZWatchReturnWithExtensionPoint' -g '!**/test/**'
echo -e "\n=== 查找扩展点的调用和注册位置 ==="
rg -nP --type=java 'BeforeCallZWatchReturnWithExtensionPoint' -g '!**/test/**' -A 2 -B 2
echo -e "\n=== 查找 BeforeApiCallExtensionPoint 的定义和使用 ==="
fd -e java -type f | xargs grep -l 'BeforeApiCallExtensionPoint' | head -5
echo -e "\n=== 查找 ZWatch 相关代码 ==="
rg -nP --type=java 'ZWatch|returnWith' -g '!**/test/**' | grep -E '(class|interface|return|with)' | head -30Repository: MatheMatrix/zstack
Length of output: 5736
🏁 Script executed:
#!/bin/bash
# Get more details on the extension point interface itself
echo "=== 查看扩展点接口定义所在文件 ==="
cat -n header/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java
echo -e "\n=== 查找同目录下的其他扩展点接口 ==="
find header/src/main/java/org/zstack/header/zql -name '*ExtensionPoint.java' -type fRepository: MatheMatrix/zstack
Length of output: 1880
🏁 Script executed:
#!/bin/bash
# Search for where extension points are registered/collected
echo "=== 查找可能的扩展点管理器或注册机制 ==="
rg -nP --type=java 'plugin.*extension|Extension.*manager|getPluginManager' -g '!**/test/**' | head -20
echo -e "\n=== 查找调用 beforeCallZWatch 的位置 ==="
rg -nP --type=java 'beforeCallZWatch' -g '!**/test/**'Repository: MatheMatrix/zstack
Length of output: 845
🏁 Script executed:
#!/bin/bash
# Search for BeforeApiCallExtensionPoint
echo "=== 查找 BeforeApiCallExtensionPoint 的定义 ==="
cat -n header/src/main/java/org/zstack/header/zql/BeforeApiCallExtensionPoint.java 2>/dev/null || echo "File not found"
echo -e "\n=== 查找 BeforeApiCallExtensionPoint 的实现 ==="
rg -nP 'implements.*BeforeApiCallExtensionPoint'
echo -e "\n=== 查找 ZQL.java 中的 callReturnWithExtensions 方法 ==="
rg -nP 'callReturnWithExtensions' -A 20 search/src/main/java/org/zstack/zql/ZQL.javaRepository: MatheMatrix/zstack
Length of output: 3846
🏁 Script executed:
#!/bin/bash
# Check PR context and git history
echo "=== 查找 BeforeCallZWatchReturnWithExtensionPoint 相关的 git 信息 ==="
git log --oneline --all | grep -i 'zwatch\|returnwith\|extension' | head -10
echo -e "\n=== 查找 BeforeCallZWatchReturnWithExtensionPoint 在 git 中首次出现的 commit ==="
git log -p --all -- '**/BeforeCallZWatchReturnWithExtensionPoint.java' | head -100Repository: MatheMatrix/zstack
Length of output: 197
🏁 Script executed:
#!/bin/bash
# Check if there's a callReturnWithExtensions implementation
echo "=== 查找涉及 BeforeCallZWatchReturnWithExtensionPoint 的完整代码段 ==="
rg -nP 'callReturnWithExtensions|BeforeCallZWatch' -B 5 -A 15
echo -e "\n=== 查找 ZQL.java 中处理 returnWith 的位置 ==="
rg -nP 'returnWith\s*=' search/src/main/java/org/zstack/zql/ZQL.java -B 3 -A 3Repository: MatheMatrix/zstack
Length of output: 8420
🏁 Script executed:
#!/bin/bash
# Final verification - check if there are any TODOs or FIXMEs related to this
echo "=== 查找相关的 TODO 或 FIXME ==="
rg -nP 'TODO|FIXME' header/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java header/src/main/java/org/zstack/header/zql/BeforeApiCallExtensionPoint.java
echo -e "\n=== 查找测试文件中的相关引用 ==="
find . -path '*/test/**' -name '*.java' -type f | xargs grep -l 'BeforeCallZWatchReturnWithExtensionPoint\|BeforeApiCallExtensionPoint' 2>/dev/null || echo "No test files found"
echo -e "\n=== 查找 PR 相关文件或描述 ==="
find . -name 'COMMIT_EDITMSG' -o -name '.git/COMMIT_EDITMSG' 2>/dev/null | xargs cat 2>/dev/null || echo "No commit message found"Repository: MatheMatrix/zstack
Length of output: 153
扩展点接口未实现且未集成,需要完成实现或移除。
经验证,BeforeCallZWatchReturnWithExtensionPoint 和 BeforeApiCallExtensionPoint 两个扩展点存在重大问题:
- 完全未实现:整个代码库中不存在任何实现类
- 完全未集成:
beforeCallZWatch()方法在任何地方都未被调用过 - 未注册扩展机制:与
pluginRgty.getExtensionList()无关联 - 接口具有误导性:接口声称提供"执行 ZQL return with 查询前的钩子"功能,但实际上该功能并不存在
实际的 return with 查询处理(ZQL.java 第 351 行和 537-557 行)使用的是不同的 ReturnWithExtensionPoint,而非这两个新扩展点。
需要采取以下任一行动:
- 在 ZQL 查询处理流程中正式集成这两个扩展点,包括实现注册和调用机制
- 或在确认不需要后完全移除这两个接口定义
🤖 Prompt for AI Agents
In
header/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java
lines 5-28, the extension interface is unused and misleading; either integrate
it into the ZQL return-with flow or remove it. To fix: if keeping, implement at
least one concrete extension, register the extension with the plugin registry
(pluginRgty.getExtensionList/registration), and invoke beforeCallZWatch(...)
from the ZQL return-with handling code paths (around the existing return-with
logic at ZQL.java lines ~351 and 537-557) passing the VO class and UUID list;
ensure supports(Class<?>) is consulted before calling. If removing, delete this
interface and any related unused BeforeApiCallExtensionPoint stubs and update
documentation and imports accordingly.
…r encountering errors in Zaku cluster. Resolves: ZSTAC-80202 Change-Id: I7778676171646874706164777869707279776172
8d8abb8 to
7f036b3
Compare
Resolves: ZSTAC-80202
Change-Id: I6b77656f6668796677626b6c6b7361696e6a6274
附属于 premium的一个MR 见
http://dev.zstack.io:9080/zstackio/premium/-/merge_requests/12525
sync from gitlab !8912