<fix>[volume-cache]: expose cache capacity fields#4211
Conversation
|
Warning Review limit reached
More reviews will be available in 26 minutes and 13 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
Warning
|
| 层 / 文件(s) | 摘要 |
|---|---|
Header 数据模型扩展 header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.java, header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventoryDoc_zh_cn.groovy |
在基础类中添加 virtualSize 和 actualSize 两个 Long 字段及其 getter/setter 方法,文档中标注新字段自版本 5.5.28 起引入。 |
SDK API 操作类实现 sdk/src/main/java/org/zstack/sdk/GetVolumeCacheAction.java, sdk/src/main/java/org/zstack/sdk/GetVolumeCacheResult.java |
实现 GetVolumeCacheAction 类用于向 /volumes/volume-cache 发送 GET 请求,包括参数映射、同步/异步调用方式和错误处理;GetVolumeCacheResult 包含 inventories 列表字段。 |
SDK 数据模型同步 sdk/src/main/java/org/zstack/sdk/VolumeCacheInventory.java |
在 SDK 端 VolumeCacheInventory 中同步添加 virtualSize 和 actualSize 字段及访问方法。 |
测试帮助方法 testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy |
新增 getVolumeCache 方法用于测试中创建并执行 GetVolumeCacheAction,支持闭包委托配置和 API 路径追踪。 |
🎯 2 (Simple) | ⏱️ ~12 分钟
🐰 卷缓存大小新添加,
虚实容量now齐全;
API 接口已完成,
测试方法配套全!
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | 标题「[volume-cache]: expose cache capacity fields」清晰准确地概括了PR的主要变更:向VolumeCacheInventory暴露缓存容量字段。 |
| Description check | ✅ Passed | PR描述详细说明了所有变更内容、测试验证过程及相关问题跟踪,与代码变更完全相关且信息充分。 |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
sync/haidong.pang/feature-5.5.6-local-cache@@3
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.java (1)
27-37:⚠️ Potential issue | 🟠 Major | ⚡ Quick win缺少新增容量字段的 VO→Inventory 映射,导致接口返回值丢失。
valueOf(VolumeCacheVO vo)未设置virtualSize/actualSize,会让本次新增字段在返回中始终为空。建议修复
inv.setCacheMode(vo.getCacheMode()); inv.setStatus(vo.getStatus()); + inv.setVirtualSize(vo.getVirtualSize()); + inv.setActualSize(vo.getActualSize()); inv.setCreateDate(vo.getCreateDate()); inv.setLastOpDate(vo.getLastOpDate());🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.java` around lines 27 - 37, The VolumeCacheInventory.valueOf(VolumeCacheVO vo) method is missing mapping for the new size fields; update valueOf to copy vo.getVirtualSize() and vo.getActualSize() into the inventory by calling inv.setVirtualSize(vo.getVirtualSize()) and inv.setActualSize(vo.getActualSize()), ensuring VolumeCacheVO’s virtualSize/actualSize are propagated to VolumeCacheInventory before returning inv.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventoryDoc_zh_cn.groovy`:
- Around line 52-63: The documentation fields for
VolumeCacheInventoryDoc_zh_cn.groovy — specifically the field entries with name
"virtualSize" and "actualSize" — have empty desc values; update their desc to
concise Chinese descriptions (e.g. virtualSize: "逻辑容量(字节)" and actualSize:
"实际占用容量(字节)" or equivalent wording) so the API docs are readable and
unambiguous; locate and edit the field blocks for virtualSize and actualSize to
set the desc strings accordingly.
---
Outside diff comments:
In
`@header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.java`:
- Around line 27-37: The VolumeCacheInventory.valueOf(VolumeCacheVO vo) method
is missing mapping for the new size fields; update valueOf to copy
vo.getVirtualSize() and vo.getActualSize() into the inventory by calling
inv.setVirtualSize(vo.getVirtualSize()) and
inv.setActualSize(vo.getActualSize()), ensuring VolumeCacheVO’s
virtualSize/actualSize are propagated to VolumeCacheInventory before returning
inv.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: fda2d717-2483-4be2-b047-f25fd8cf2c44
📒 Files selected for processing (6)
header/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventory.javaheader/src/main/java/org/zstack/header/volumeCache/VolumeCacheInventoryDoc_zh_cn.groovysdk/src/main/java/org/zstack/sdk/GetVolumeCacheAction.javasdk/src/main/java/org/zstack/sdk/GetVolumeCacheResult.javasdk/src/main/java/org/zstack/sdk/VolumeCacheInventory.javatestlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
Expose runtime capacity fields on VolumeCacheInventory for GetVolumeCache, and include generated API docs, Java SDK action/result, and ApiHelper surface. Resolves: ZSTAC-85172 Change-Id: I9db2260710e085de51213538f1dba31053b27af1
7a3b393 to
a4e53f4
Compare
Summary
Expose runtime volume cache capacity fields on VolumeCacheInventory for the new GetVolumeCache API response, and publish the generated Java SDK/API helper surface for the same API.
Changes
Testing
Notes:
scripts/backend-build-container/container-run test-premium VolumeCacheCasehit an environment resource failure (Too many open files in system) before executing the case (Tests run: 0). The direct clean Maven run above passed.Resolves: ZSTAC-85172
sync from gitlab !10084